7

I'm trying to download a file from a linux server i'm already connected to. I know you can use scp to connect to and pull down a file from a host, but that requires still being on local. I could scp the file back to my local machine, but the local machine is not accessible from the host.

Is there a way to just pull down the file you are already looking at? Something like:

From the host

$ download <THEFILE>

This would really just be more convenient than having to go back out to my local terminal than scp the file. Instead you could just say "grab this one" Done.

I suppose the client would have to know what to do with the file. And i'm pretty sure "terminal.app" does not have a default downloads folder. So perhaps this is not possible.

BTW I'm connect from a mac to Debian.

  • " but the local machine is not accessible from the host." Can you scp from the debian to the mac? – jc__ Jul 13 '16 at 17:21
  • If you're using the new release of iTerm, you can install shell integration, which will allow you to right-click a file and download it to your local host. This is basically a shortcut for opening a new terminal tab or window and simply typing scp user@host.example.com:/path/to/file ~/Downloads/ – DopeGhoti Jul 13 '16 at 19:31
  • Just downloaded iTerm and it actually did the job. But it required using an alt terminal app, and i had to install shell integration on the remote server. I might keep using this since iTerm seems pretty powerful. But Jakuje's answer is more inline with what I was looking for. – Scott Stamile Jul 13 '16 at 20:50

2 Answers2

3

Your machine hostname is not resolvable from the remote host. You should do this the other way round. From your local host:

scp xyz@remote:/home/user/test /home/user

Or the other way is to set up remote port forwarding, so you will be able to connect from your remote machine to your local host. Your command can look like this:

[local] $ ssh -R 2222:localhost:22 remote
[remote]$ scp -P 2222 /home/user/test xyz@localhost:/home/user

Inspired by my answer on SO

Jakuje
  • 21,357
0

If I understand your question, You are sitting in front of the mac and have a ssh into the debian. You see a file on the debian that you want on your mac. You do not want to 'pull' the file from the debian to the mac because you must switch terminals.

Use scp to 'push' the file from the debian terminal.

scp /local/file/on/debian mac_user@mac:/downloads

/downloads on the mac must be accessible by the mac_user

jc__
  • 2,605
  • "I could scp the file back to my local machine, but the local machine is not accessible from the host." – phemmer Jul 13 '16 at 17:23
  • 1
    Is that because of a mac limitation like firewall or ssh server nor running, or is it a debian limitation because of... ?? an ip rule... – jc__ Jul 13 '16 at 17:25
  • it's because the mac i'm using is on a closed network. so my mac is not accessible from outside our network. In this example the host would be a media temple web server. – Scott Stamile Jul 13 '16 at 18:13