Create symbolic links on server without SSH available?
Asked Answered
F

3

32

I got excited when I saw the following post but it doesn't cover my case: Mount an FTP server locally

Is there any way for me to create symbolic links on a remote server without having SSH access, possibly via some FTP hack?

Foulup answered 8/4, 2011 at 1:31 Comment(0)
S
19

Regular FTP is too abstract to know about symbolic links.

If the server supports custom commands, it might let you send the unix shell commands directly. Not all servers support this but some of them do.

If you have SFTP access (sometimes admins give users SFTP access but no SSH shell), SFTP protocol supports creation of symbolic links.

Stunning answered 8/4, 2011 at 6:48 Comment(2)
This is excellent information. I checked out my FTP client (FlashFXP) and sure enough it has the ability to execute raw commands on the server. Sure enough it worked. Thank you :)Foulup
For those that don't have an SFTP access, you may still use a script. Check my answer below.Swatter
S
31

Use a script.

If you have sh, bash or csh available, then you're nearly as good as if you had an ssh access. If you don't, then most other scripting languages allow you to create symbolic links on your server.

For example, in PHP you would use the symlink() function:

 symlink("myOriginalFileOrDirectory", "mySymbolicLink"); 

I just had the same problem, and this is how I easily solved it :)

Swatter answered 15/6, 2012 at 12:8 Comment(7)
This approach will only work in a situation when the FTP server is also a web server or when you have shell (telnet or SSH) access. With pure FTP server this is not possible.Smelser
Right, I was considering the common case of using an FTP server as a means to upload your files on your web server.Swatter
Even with a web server (say shared hosting) you not always are allowed to run shell scripts which access the filesystem this way.Smelser
Well, you'll surely have noticed that shell scripts aren't the only scripts that allow access to filesystem, especially since the example I gave involved PHP. If you don't have any scripting tool allowed on your shared hosting, then maybe it's time to consider changing your hosting provider :)Swatter
PHP can be also limited in access to just some folders (which rules out the PHP script from solution)Smelser
FTP can also be limited in access to just some folders. In any case, that does not rule out anything unless you're trying to link something in the specific places your hosting provider has decided you shouldn't go, so that's not very relevant. Look, if I'm going to list every particular configuration that might hamper the creation of a symbolic link it's not going to be helpful to someone who tries to find a practical solution to his problem. It would be more constructive if you proposed working alternatives for those cases where my solution doesn't work, instead of just bashing it.Swatter
I am facing same. Where should I place this and how to execute this? by cronjob? @SwatterAnabas
S
19

Regular FTP is too abstract to know about symbolic links.

If the server supports custom commands, it might let you send the unix shell commands directly. Not all servers support this but some of them do.

If you have SFTP access (sometimes admins give users SFTP access but no SSH shell), SFTP protocol supports creation of symbolic links.

Stunning answered 8/4, 2011 at 6:48 Comment(2)
This is excellent information. I checked out my FTP client (FlashFXP) and sure enough it has the ability to execute raw commands on the server. Sure enough it worked. Thank you :)Foulup
For those that don't have an SFTP access, you may still use a script. Check my answer below.Swatter
I
11

RFC 959 defines the FTP protocol, and does not offer any standard provisions for creating symbolic links.

Ima answered 8/4, 2011 at 1:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.