Let’s start learning Secure FTP, SFTP

We are very much familiar with FTP server and its client for uploading and downloading files from server. But most of us don’t know about SFTP.  SFTP is basically SSH File Transfer Protocol and also known as Secret File Transfer Protocol or secure FTP. It uses Secure Shell protocol (SSH) to transfer,  access and manage files. It encrypts both command and data so that data to be transmitted over net is secure. Name of this protocol is similar to FTP, but it can not work with FTP server and FTP client also can not work with SFTP server.

It has some nice graphical clients. We can use WinSCP for windows and Cyberduck for MAC. But command line is widely used for SFTP. From Unix, Linux and Mac OS X , we can use it at CLI (Command-line Interface). To use SFTP at CLI, we will have to start SFTP session. Open the terminal and type.

sftp username@hostaddress 

For example, if your want to connect your host: eftakhairul.com with username root. Then your command will be

sftp [email protected]

It will prompt for your password. Enter your password and SFTP session will start.  There are some standard commands for SFTP. Just take a look.

On remote Computer

cd  -  Change the directory on the remote computer
chmod  - Change the permissions of files on the remote computer
chown  - Change the owner of files on the remote computer
ls -  List the files of  directory on the remote computer
pwd - Show path on the remote computer
ln (or symlink) Create a symbolic link for a file on the remote computer
mkdir -  Create a new directory on the remote computer
rename - Rename a file on the remote host
rm  - Delete files from the remote computer
rmdir - Remove a directory on the remote host
put - upload a file from  the local computer to the remote computer
Local computer from remote computer lcd  - Change the directory on the local computer lls  - List of the files of directory on the local computer lmkdir -  Create a directory on the local computer lpwd - Show the path on the local computer lumask - Change the local umask value. quit - Close the connection to the remote computer and close the sftp session.

Related Link: http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol

By Eftakhairul Islam on October 24, 2011 · Posted in Linux, Tutorials

5 Comments | Post Comment

Mustafa Zaman says:

Indeed a very nice article. However, it will be better if you can describe a bit more what is the benefit of using SFTP and how anyone can use it. Most importantly what are things that needed to ensure to work with SFTP.

Posted on October 24th, 2011

eftakhairul says:

Thanks Mr. Zaman for your nice question. If you don’t have FTP server installed in your host, but you have the ssh server installed. Then you can go for sftp for uploading and downloading files.

Posted on October 24th, 2011

Mustafa Zaman says:

How about I have the both.. FTP and SSH.. Will it work then??

Posted on October 24th, 2011

eftakhairul says:

Yup. Both will work. Because, both of them use different protocols.

Posted on October 24th, 2011

Jackson says:

Nice article 🙂

SFTP should not really be referred to as Secure FTP, but as the SSH File Transfer Protocol as you mentioned first.

FTP over SSH (not SFTP and not FTPS) is commonly referred to as Secure FTP.

Posted on October 27th, 2011