Here are some ways to download file from SSH to local machine, be it Linux or a Mac. Sometimes we need to download just one file for some reason. It is quite obvious that, for more number of files, we can use SFTP. These commands will work on OS X (Terminal, iTerm2) or GNU Linux. It is difficult to say whether these will work with puTTY, may be with CygWin, it is possible to use the commands. Windows users possibly need this kind of setup – Translucent Console for Windows.
Download File From SSH to Local Machine : Some Knowledge is Required!
Actually there are lot of ways to download a file from SSH session. But, if you know about Pipe or Pipeline, then it becomes quite easy.Advertisement
Download File From SSH to Local Machine
Worst method probably is using
scp. Because, we are frankly cheating – there are differences between FTP and SSH. We can not say that we are using SSH, the Terminal software only remaining the same. Here is example :
# copy a file from B to A while logged into B
scp /path/to/file username@a:/path/to/destination
# copy a file from B to A while logged into A
scp username@b:/path/to/file /path/to/destination
This cheating answer is usually found on Question-Answer websites. Piping is the right, genuine pure SSH way :
# First easy method
ssh host 'cat /path/on/server' > /path/on/local
# using pipe, with only one server
cat /path/on/local | ssh username@IP 'cat > /path/on/server'
# using pipe, with two servers, local is just a machine in between
ssh username@IP 'cat /path/on/server1' | ssh username-2@IP-2 'cat > /path/on/server2'
There is a package named
ssh-xfer, this works both for puTTY and Terminal. We have less idea about this, you can check this page :
A bit kind of ‘modern’ method is using this :
Obviously, if you want to go via either very complicated method or vulnerable method, you can mount. Mounting is practical on Physical Dedicated server or Bare Metal or Colocation.