ssh to target, scp back to source in same session without name resolution

Bob Proulx bob at proulx.com
Wed Apr 13 18:31:32 EST 2005


lars wrote:
> "Problem":
> I'm behind a firewall with my source host,
> I don't know the name or location of some files/directories on the 
> target host,

This is a bash specific suggestion.  It probably works with other
shells that also have command completion.  Use file name expansion to
see the name of the file you want to copy.

  . /etc/bash_completion
  scp user at remote:/some/path<TAB><TAB>

At the TAB the shell as configured by the completion will ssh to the
remote host and get a directory listing as if it were expanding a
local path.  Find the file you want, select it and then copy it
locally.

  scp user at remote:/some/path/to/file .

Depending upon the speed of the hosts involved this either is either
very fast or possibly quite slow.  You will need to be managing ssh
keys with an agent or it will prompt you repeatedly for passwords.
But it is a pretty nice feature.

Bob




More information about the openssh-unix-dev mailing list