ssh: leave channel open for fast copies

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?


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.


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).