The sftp command allows a user to retrieve files on a remote machine and save them on their computer.
Use this command to access the files: sftp -P 443 [email protected]:/home/homer/Downloads/*.pdf
I have my SSH server running on port 443, so I need to specify that port when using this command. I am using Cygwin on Windows Server 2012 R2, but this will work the same way on a Linux client.
Administrator@WIN-EM8GK0ROU41 ~ $ sftp -P 443 homer@192.168.100.2:/home/homer/Downloads/*.pdf homer@192.168.100.2's password: Connected to 192.168.100.2. Fetching /home/homer/Downloads/George_Martin_-_A_Game_of_Thrones.pdf to George_Martin_-_A_Game_of_Thrones.pdf /home/homer/Downloads/George_Martin_-_A_Game_of_Thrones.pdf 100% 5905KB 1.9MB/s 00:03 Fetching /home/homer/Downloads/ISBSprogram6_16.pdf to ISBSprogram6_16.pdf /home/homer/Downloads/ISBSprogram6_16.pdf 100% 1911KB 1.9MB/s 00:01 Fetching /home/homer/Downloads/codenomicon-wp-smart-tv-fuzzing.pdf to codenomicon-wp-smart-tv-fuzzing.pdf /home/homer/Downloads/codenomicon-wp-smart-tv-fuzzing.pdf |
This is a perfect way to access a file on your home server machine if you left it behind and you have SSH access.
Administrator@WIN-EM8GK0ROU41 ~ $ ls -hula total 12M drwxr-xr-x+ 1 Administrator None 0 Jul 3 13:19 . drwxrwxrwt+ 1 Administrator None 0 May 22 05:10 .. -rw------- 1 Administrator None 1.6K May 22 05:30 .bash_history -rwxr-xr-x 1 Administrator None 1.5K May 22 05:07 .bash_profile -rwxr-xr-x 1 Administrator None 6.0K May 22 05:07 .bashrc drwx------+ 1 Administrator None 0 May 22 05:29 .cache drwx------+ 1 Administrator None 0 May 22 05:29 .config -rwxr-xr-x 1 Administrator None 1.9K May 22 05:07 .inputrc drwx------+ 1 Administrator None 0 May 22 05:29 .local -rw-r--r-- 1 Administrator None 116 May 22 05:19 .minttyrc -rwxr-xr-x 1 Administrator None 1.3K May 22 05:07 .profile drwx------+ 1 Administrator None 0 Jun 6 15:52 .ssh -rw-r--r-- 1 Administrator None 3.9M Jul 3 13:19 codenomicon-wp-smart-tv-fuzzing.pdf drwxr-xr-x+ 1 Administrator None 0 May 23 11:19 Documents -rw-r--r-- 1 Administrator None 5.8M Jul 3 13:19 George_Martin_-_A_Game_of_Thrones.pdf -rw-r--r-- 1 Administrator None 12K May 22 12:23 index.html -rw-r--r-- 1 Administrator None 12K May 22 12:27 index.html.1 -rw-r--r-- 1 Administrator None 12K May 23 11:13 index.html.2 -rw-r--r-- 1 Administrator None 1.9M Jul 3 13:19 ISBSprogram6_16.pdf -rw-r--r-- 1 Administrator None 78 May 23 11:14 my.c -rw-r--r-- 1 Administrator None 2.7K May 23 11:18 my.o |
Now I have the files on my local machine. This is one very useful trick to use when you are accessing an SSH server.
From my own personal experience I would recommend rsync (via ssh) over SFTP because rsync is much faster than SFTP, especially when copying many small files.