2

One can log into a remote shell via SSH, and one can use an FTP application to log in via SFTP using the same credentials over SSH. How then, does one initiate a file transfer from the remote host to the local host when logged into a shell via SSH?

I know that I could use scp or rsync to move the files, but the requires authenticating which is not something that I can always do from the host. From my limited understanding the existing SSH connection is all that should be needed, as SSH has file transfer capability.

Thanks.

dotancohen
  • 30,064
  • 36
  • 138
  • 197

1 Answers1

1

So from local host A, you log in to remote host B, and want to transfer a file from B back to A?

You need a server of some sort on A to handle the request, or pull it from B when you're logged in to A.

Is it possible to set up authorized_keys on the servers to facilitate password-free authentication?

EDIT: On *nix hosts, you can get the package zssh on A and lrzsz on B. Then instead of ssh B you run zssh B, cd to the directory you want to get a file from, run sz file.name then hit ctrl+space and enter rz, and it will transfer locally. Other clients may have other methods.

TaoJoannes
  • 594
  • 5
  • 14
  • Yes, you asess correctly. Local host A is running an SSH client, and remote host B is running an SSH server. From my limited understanding that is all that should be needed, as [SSH has file transfer capability](http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol). – dotancohen Apr 23 '12 at 15:29
  • Then you can pull from A to B, when logged in to A (via scp, sftp, etc), but pushing from B to A while logged in to B via ssh would require a file transfer server on A, whether ssh, ftp, smb, whatever is immaterial, but there needs to be something there to catch it. – TaoJoannes Apr 23 '12 at 15:43
  • So the existing running SSH client could not catch a push from B to A? – dotancohen Apr 23 '12 at 15:54
  • not without some sort of server on A. This thread explores it in some detail. http://stackoverflow.com/questions/440524/ssh-a-way-to-transfer-files-without-opening-a-separate-sftp-session – TaoJoannes Apr 23 '12 at 16:03
  • of course, it's dependant on what you're running on A, some ssh clients have a facility for this. – TaoJoannes Apr 23 '12 at 16:06
  • Thank you Tao, The linked thread has some workarounds that I can use. Accepting this, then, as the answer. Which SSH clients do have the facility to receive the pushed files? I use OpenSSH in Debian mostly, but I am flexible. Thanks. – dotancohen Apr 23 '12 at 16:08
  • 1
    I added some info to the answer, `zssh` and `lrzsz` together seem to work pretty well. I tested them on debian and ubuntu just now. Neat question. – TaoJoannes Apr 23 '12 at 16:14
  • Thank you for the followup Tao! That may be a good solution for the machines to which I have root access or can get the admin to install a package on. – dotancohen Apr 23 '12 at 16:35