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?

Community
  • 1
  • 1
nero
  • 521
  • 1
  • 7
  • 19

3 Answers3

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 :)

KPM
  • 10,558
  • 3
  • 45
  • 66
  • 2
    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. – Eugene Mayevski 'Callback Jun 16 '12 at 05:52
  • 3
    Right, I was considering the common case of using an FTP server as a means to upload your files on your web server. – KPM Jun 17 '12 at 00:01
  • Even with a web server (say shared hosting) you not always are allowed to run shell scripts which access the filesystem this way. – Eugene Mayevski 'Callback Jun 17 '12 at 06:03
  • 2
    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 :) – KPM Jun 17 '12 at 15:50
  • PHP can be also limited in access to just some folders (which rules out the PHP script from solution) – Eugene Mayevski 'Callback Jun 17 '12 at 16:08
  • 3
    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. – KPM Jun 17 '12 at 23:51
  • I am facing same. Where should I place this and how to execute this? by cronjob? @KPM – VijayRana Mar 20 '18 at 16:14
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.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • 1
    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 :) – nero Apr 12 '11 at 21:16
  • For those that don't have an SFTP access, you may still use a script. Check [my answer below](http://stackoverflow.com/a/11050356/364446). – KPM Jun 15 '12 at 20:42
11

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

Community
  • 1
  • 1
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285