Reverse SCP over SSH connection
This would be a lot easier with SFTP, which is an extension to SSH that supports more complex file operations than SCP. Virtually all modern Unix and Linux distributions support it. To use it, just run this command to connect to the server:
sftp server
Then you can use the ls
and cd
commands to browse around and find the file you're looking for. Once you've found it, use the get
command to download it. For instance, to download file.txt
in your current working directory on the server to your current working directory on your local machine, just run:
get file.txt
To download /home/pavpanchekha/textfiles/file.txt
on the server to ~/textfiles/
on your local machine, instead run:
get /home/pavpanchekha/textfiles/file.txt ~/textfiles/
Conversely, you can also upload files in this manner. To upload file.txt
from your local current working directory to the current working directory of the server, type:
put file.txt
You can also use full paths for each like you can with get
:
put ~/textfiles/file.txt /home/pavpanchekha/textfiles/file.txt
For a full list of available SFTP commands, just run help
at the sftp>
prompt.