Is it possible to SCP from a remote to local whilst logged into the remote and without knowing the local's IP address?

You can use SSH tunneling for this.

Using tunneling you can forward a TCP port either from your local machine to the remote machine, or from the remote machine to your local machine. I use it frequently to forward e.g. SMTP or IMAP ports from a remote machine behind a firewall to my local machine (and then access the services locally, as if they were running locally).

To forward port 22 (SSH) from you local machine to the remote machine try this:

ssh -R12345:localhost:22 yourremoteuser@remotemachine

(Note that localhost refers to the local name of the remote machine)

After running this you should be able to ssh back home using:

ssh -p12345 [email protected]

When using scp, you would do something like (scp has an uppercase P for port forwarding):

scp -P12345 filename 127.0.0.1:/tmp/filename

Port forwarding in the other direction (from remote to local) uses -L instead of -R.

The above commands assume that you are using a terminal ssh client. Graphical clients, like PuTTY for Windows, also support tunneling


Try the following in the command line from the remote machine, you may need to enable port forwarding on your router.

scp <file on remote machine> ${SSH_CLIENT%% *}:<directory on local machine>

Source: Easily scp a file back to the host you're connecting from (commandlinefu.com)


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.

Tags:

Scp

Local

Remote