ssh: leave channel open for fast copies

5

2

I have a high latency connection to a remote system. I'm debugging a script on the remote system, and thus repeatedly copying a small file via scp.

This is annoying because it has to re-authenticate (using pubkey) each time and the whole process takes longer than it should.

Is there a port forward or something I can set up would make the copy bypass authentication? Is there a recipe for this?

bstpierre

Posted 2010-09-09T14:40:06.223

Reputation: 1 232

Answers

6

You could enable connection sharing. You would keep a single connection open (e.g. use it for work on the remote site) and use that same connection to copy with scp.

To activate it you need in your ~/.ssh/config

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

ControlPath is the path to the socket for the shared connection. Above example creates a dynamic name from login and hostname.

Benjamin Bannier

Posted 2010-09-09T14:40:06.223

Reputation: 13 999

+1 Excellent, that's exactly what I needed. Thanks. – bstpierre – 2010-09-09T16:06:42.260

3

Despite the good answers already given (in fact this extends the answer on sftp): Using sshfs (using FUSE) to mount the remote working directory onto your local machine is also a nice transparent solution: sshfs [user@]host:[dir] mountpoint [options] and `fusermount -u mountpoint to unmount).

Hannes

Posted 2010-09-09T14:40:06.223

Reputation: 206

2

Using SFTP (via sftp) will allow you to hold the connection open and transfer as many times as needed provided the server has the SFTP subsystem enabled.

Ignacio Vazquez-Abrams

Posted 2010-09-09T14:40:06.223

Reputation: 100 516