1

I know that you can grab files with scp like this:

scp user@remote_machine:/path/to/source /path/to/destination

However, I'd like to know if there is an easier way to do this, when I'm already logged on in ssh on the remote machine - that is, to avoid specifying username, hostname and absolute path to source?

Flyk
  • 1,539
  • 1
  • 21
  • 28
Septagram
  • 5,348
  • 6
  • 20
  • 21
  • Something like this? - http://superuser.com/questions/291034/is-it-possible-to-scp-from-a-remote-to-local-whilst-logged-into-the-remote-and-w – Bibhas Jan 19 '12 at 09:10
  • @Bibhas, yes, but it doesn't provide an *easier* way to solve the problem... – Septagram Jan 20 '12 at 08:03

2 Answers2

3

Maybe zssh?

zssh (Zmodem SSH) is a program for interactively transferring files to a remote machine while using the secure shell (ssh). It is intended to be a convenient alternative to scp , allowing to transfer files without having to open another session and re-authenticate oneself.

zssh is an interactive wrapper for ssh

It uses the venerable rz, sz implementations of zmodem file transfer.

RedGrittyBrick
  • 81,981
  • 20
  • 135
  • 205
  • Thanks, this is the best solution so far. It is a bit inconvenient, but gets the job done. Do you happen to know how to transfer directories recursively? `find -type f | xargs sz` didn't help me for some weird reason, the only way I found was to compress them into some kind of archive, like this: `tar c directory/ | sz -`. – Septagram Jan 20 '12 at 08:39
1

You could add the host information to your ~/.ssh/config, something like:

Host            foo
HostName        foo.baz.com
User            bar

And then you can do scp foo:~/path/to/file instead of scp bar@foo:~/path/to/file, or alternatively you can setup an alias or function to do the same thing.

As for your actual question, I don't know. scp creates a new connection to transfer files and doesn't use the existing ssh connection.

Ammar Alammar
  • 491
  • 3
  • 6