How to list the symbolic links with sftp?

6,710

The OpenSSH SFTP client does not currently support this.

#ifdef notyet
char *
do_readlink(struct sftp_conn *conn, const char *path)
{
    …
}
#endif

This is the only occurrence of SSH_FXP_READLINK in the OpenSSH source code. I don't know why this is commented out or what it would take to make it work. The only relevant message I can find on the OpenSSH mailing list is a patch from 2002 that wasn't adopted.

So your only option is to use a different SFTP client, such as SSHFS or curl.

Share:
6,710

Related videos on Youtube

Mikhail T.
Author by

Mikhail T.

The more you know, the fewer people you can ask.

Updated on September 18, 2022

Comments

  • Mikhail T.
    Mikhail T. almost 2 years

    Our hosting provider does not allow ssh-access (because security), but lets us upload files and manipulate directories via sftp. (The only other choice is through "cpanel").

    sftp is good enough to allow creating the symbolic links, but not good enough to properly list them. For example:

    sftp> symlink 500 rwu
    sftp> ls -l
    lrwxrwxrwx    1 foo bar  3 May 22 16:27 rwu
    

    That is, I can see the fact that "rwu" is a symlink, but I can not see to what. At least, not by default. Is there some "hidden" option to the entire sftp-client or its ls-command, that would list symlinks properly -- the way the real ls(1) would?

  • Martin Prikryl
    Martin Prikryl about 7 years
    FileZilla cannot display link target either. +1 anyway
  • meuh
    meuh about 7 years
    Some versions of curl can do sftp too. If you use the url of the directory it will show the typical ls -l output with -> for symbolic links.