ftp supports the put "|..." "remote-file.name"
command to pipe data to an ftp connection. Is there something similar available for sftp?
In sftp i get the following error:
sftp 'jmw@backupsrv:/uploads'
sftp> put "| tar -cx /storage" "backup-2012-06-19--17-51.tgz"
stat | tar -cv /storage: No such file or directory
as above the sftp client doesn't obviously execute the command.
i want to use the pipe command to directly redirect the file stream to sftp. (because there is not enough space left to create a backup file on the same disk before uploading it to sftp server.)
Best Answer
As this is the first result you find by googling for this question and it hasn't been mentioned already I'll add the solution I found here as well:
you can use curls sftp implementation for this. As curl is probably already installed on a lot of systems this might be preferred to the solution using custom clients.
example usage:
curl
uses your.ssh/known_hosts
file for key verification. This might fail in case your ssh client does use newer encryption standards not supported by the library used in curlto fix this you can add the other key types to the known hosts file using the following command:
or you can disable key verification using the
-k
flag (I wouldn't recommend that though)