The sftp utility for Linux allows copying files from a remote Linux machine, or sending them to one, this makes working with a machine over SSH very easy.
Firstly, connect to the machine like this.
deusexmachina:~ jason$ sftp jason@192.168.1.4 jason@192.168.1.4's password: Connected to 192.168.1.4. |
Then issue the ls command that is built into sftp. This shows the files that are available in the home directory.
sftp> ls 278th_ACR_V1.Altis.pbo @insurgency @insurgency.zip Apex-Framework-master.zip Apex_framework.Altis.pbo Apex_framework_108.Altis.pbo Arma3.cfg Desktop Documents Downloads Music Pictures Public Steam Templates Videos alive altis_insurgency_altis.altis.pbo examples.desktop init.txt po_21_rhs.altis.pbo steamcmdstuff |
Now retrieve a file from the remote machine.
sftp> get po_21_rhs.altis.pbo Fetching /home/jason/po_21_rhs.altis.pbo to po_21_rhs.altis.pbo /home/jason/po_21_rhs.altis.pbo 100% 2213KB 14.5MB/s 00:00 sftp> |
To change directory when logged into a remote computer using sftp, use the cd command.
deusexmachina:~ jason$ sftp jason@192.168.1.4 jason@192.168.1.4's password: Connected to 192.168.1.4. sftp> cd Documents sftp> ls altis_insurgency_altis.pbo pg768.txt rhsafrf.0.4.5.bikey rhsgref.0.4.5.bikey rhssaf.0.4.5.bikey rhsusaf.0.4.5.bikey |
Here are the available commands that may be used while logged in.
sftp> ? Available commands: bye Quit sftp cd path Change remote directory to 'path' chgrp grp path Change group of file 'path' to 'grp' chmod mode path Change permissions of file 'path' to 'mode' chown own path Change owner of file 'path' to 'own' df [-hi] [path] Display statistics for current directory or filesystem containing 'path' exit Quit sftp get [-afPpRr] remote [local] Download file reget [-fPpRr] remote [local] Resume download file reput [-fPpRr] [local] remote Resume upload file help Display this help text lcd path Change local directory to 'path' lls [ls-options [path]] Display local directory listing lmkdir path Create local directory ln [-s] oldpath newpath Link remote file (-s for symlink) lpwd Print local working directory ls [-1afhlnrSt] [path] Display remote directory listing lumask umask Set local umask to 'umask' mkdir path Create remote directory progress Toggle display of progress meter put [-afPpRr] local [remote] Upload file pwd Display remote working directory quit Quit sftp rename oldpath newpath Rename remote file rm path Delete remote file rmdir path Remove remote directory symlink oldpath newpath Symlink remote file version Show SFTP version !command Execute 'command' in local shell ! Escape to local shell ? Synonym for help |
Use the ! command within sftp to temporarily escape to your local machine, then type exit to change back to the sftp prompt.
This is a very useful tip for copying files across a network. Good to know when working with a Linux LAN, or a machine on the Internet.