Can you use SFTP to transfer files "backwards" to client during SSH on host?

1

1

While connected to a host computer in Linux (Ubuntu) in command prompt I often find the need to transfer files back to my client computer. I was wondering if Linux offers the capability to move these files through SFTP or any other mechanism.

Ryan Ward

Posted 2018-02-14T05:24:50.683

Reputation: 404

Answers

1

If you mean transfer the files without opening a new session from your current system, then the answer is probably no, you will need to do a new session of some kind to your target computer. Some SSH utilities open multiple sessions to make file transfers easier. However, if you're typing on Host A, and SSH'd into Host B, then you can SCP from Host B to Host A:

hostb $ scp catphoto.jpeg me@hosta:/home/me/Pictures

That won't require you to do anything other than type the password of Host A, assuming Host A is running sshd or some other SSH server utility. If it's not, and I'm talking about Windows here, I've had some luck with Windows 10's developer mode enabling SSH servers which this article talks about nicely.

Alternatively, mobaxterm is one of the clients I've used with a handy explorer-style file transfer bar, click and drag to bring it over.

robb manes

Posted 2018-02-14T05:24:50.683

Reputation: 19

0

There's no way to initiate a file transfer back to local machine using an existing SSH session to a remote machine.

Alternative approaches (some are probably obvious):

  • If the local machine runs SFTP (or FTP) server, you can of course "upload" the files to the local machine using command-line SFTP (or FTP) client.

  • You can use SFTP/SCP client on local machine to download the files from the remote machine, using the same credentials that you use for SSH.

  • Some SSH clients support connection-sharing.

    For example PuTTY. While you still need to run a compatible file transfer client (the pscp or psftp), no new login is required, it automatically (if enabled) makes use of an existing PuTTY SSH session.

    To enable the sharing see:
    Sharing an SSH connection between PuTTY tools.

Martin Prikryl

Posted 2018-02-14T05:24:50.683

Reputation: 13 764