Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH - a way to transfer files without opening a separate SFTP session?

Not really a programming question, but relevant to many programmers...

Let's say I have opened an SSH session to another computer.

remote:html avalys$ ls
welcome.msg index.html readme.txt
remote:html avalys$

Is there any command that I can type in my remote shell that will immediately transfer one of the files in the current directory (e.g. welcome.msg) to my local computer, i.e.

remote:html avalys$ stransfer welcome.msg
Fetching /home/avalys/html/welcome.msg to welcome.msg
/home/avalys/html/welcome.msg 100% 23KB 23.3KB/s 00:00
remote:html avalys$

The only way I know of to do this is to open a parallel SFTP session and CD to my current directory in the SSH session, which is a real PITA when administering a server remotely.

EDIT: I am aware of the possibility of using a reverse sftp/scp connection, but that involves more typing. It would be great if I could type just the name of some command (e.g. "stransfer"), and the file(s) I want transferred, and have it Just Work.

like image 430
avalys Avatar asked Jan 13 '09 19:01

avalys


People also ask

Does SFTP work over SSH?

SFTP File Transfer Protocol - get SFTP client & server. SFTP (SSH File Transfer Protocol) is a secure file transfer protocol. It runs over the SSH protocol. It supports the full security and authentication functionality of SSH.

Can I use SSH to transfer files?

It's based on the SSH protocol used with it. A client can use an SCP to upload files to a remote server safely, download files, or even transfer files via SSH across remote servers.


2 Answers

You could set up such an inverted transfer connection w/

ssh -Rport:127.0.0.1:22 user@host

for scp back.

Use scp user@host:port to access it.

like image 61
Joshua Avatar answered Oct 19 '22 03:10

Joshua


In researching this I found a program that works as a drop-in replacement for the openssh client, zssh.

sudo apt-get install zssh
zssh user@remote
sudo apt-get install zssh
sz file.name
<ctrl>+<space>
rz

Works like a charm.

like image 27
TaoJoannes Avatar answered Oct 19 '22 03:10

TaoJoannes