1

I'm often working on my laptop on the move, while being logged in on my working station via SSH. Sometimes I might want to download a file to my local laptop, and since I most likely do not have port forwarding set up where I happen to work for the moment, it means the following process:

  1. Find what file I'm looking for on my workstation and copy its path.
  2. Open a new terminal window, write scp -P 28 user@workstation.company.com:path/to/file .

What I'm looking for is a way to download it locally in the first step already, without having to do all the hassle of opening new terminal windows, etc. Any ideas?

  • tmux or screen can help with easily creating new terminal windows. – Vreality Mar 10 '14 at 11:23
  • I'd appreciate feedback on my answer (positive or not). – Vreality Mar 17 '14 at 19:58
  • ssh doesn't work this way. Kermit used to do this. I suggest aliases – Rich Homolka Mar 21 '14 at 3:26
0

EDIT:

You can use Midnight Commander, a ncurses file manager to access remote systems via fish, sftp, or ftp. All you need is ssh running on the remote service and mc installed on your client. Start Midnight Commander

$ mc

and then run sh://[user@]machine[:options]/[remote-dir] or sftp://[user@]machine:[port]/[remote-dir] within its built in shell. For example:

sh://user@remote.host.com:/home/user/

This can be particularly useful since it allows you to easily view, edit, or list files locally and remotely.

You can read more about mc via its man page.

Old Answer below:

The only solution that I've found that uses an already existing connection in the same window is ssh-xfer. Once it's installed/patched, you just need to invoke it like this:

ssh-xfer filename.extension

However, I've never tried this method, so I can't help you with its implementation.

Alternatively, if you want to just reuse the connection (this still requires another window), you can look into setting up the ControlMaster/ControlPath in your ~/.ssh/config file like so:

host *
    controlmaster auto
    controlpath /tmp/ssh-%r@%h:%p

For more information about this, check out this link.

| improve this answer | |
  • Thanks for your suggestions. Unfortunately I never got it to work (no error messages to share), so I sort of accepted having to continue using my old method. – Jimmy C Mar 18 '14 at 20:40
  • @JimmyC Try the mc solution that I edited in; I think that'll fit your needs nicely. – Vreality Mar 21 '14 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.