Search code examples
bashcommand-linesftp

How do I pass a full SFTP URL to the sftp command?


I have a website that provides SFTP links in the format sftp://user@host.com/path/to/file.zip. To get this working via command line, I need to copy the link, and either run sftp user@host and then paste the path into the resulting shell:

$ > get /path/to/file.zip

Or I need to manipulate the URL into something like sftp user@host.com:/path/to/file/zip

Today I saw someone just run sftp sftp://user@host.com/path/to/file.zip and it worked just fine. When I do this it seems that sftp interprets the file path as part of the host and says

ssh: Could not resolve hostname host.com/path/to/file.zip

How can I get it working such that I can just run this? sftp sftp://user@host.com/path/to/file.zip


Solution

  • The URL syntax is supported by OpenSSH 7.7 and newer only.

    As OpenSSH 7.7 is relatively new (2018-04-02), it is quite probable that you are using an older version.

    Se also a related question Using sftp like scp.