Build Your Own Blog Like This One

Building a Blog Has Never Been so Easy! Mobile Optimized and Easy -to-add

SFTP: Know What It Is, How It Is Used and Its Main Commands

To upload or download files on the Internet, there are a variety of protocols.

Among the many protocols is FTP or File Transfer Protocol, which is responsible for uploading or downloading files to the server where a website is stored, or an information repository, for example, in your hosting account.

The problem is that FTP is more than 50 years old since it was created and as computer attacks become more and more sophisticated, it was necessary to find a replacement that offered more protection.

SFTP is the protocol intended to replace FTP and below you will find out what it is and how you can use it.

 

What is SFTP?

SFTP or (Shell File Transfer Protocol), is a mix between FTP and SSH (Secure Shell Protocol), but it was developed from scratch. The truth is that although it replaces FTP, it is more of a security mechanism that transfers files.

SSH adds encryption to authentication data and files so that they cannot be seen or interpreted by attackers on the network. This offers greater security to users, especially when it comes to sensitive or confidential information.

 

How to Use the SFTP Protocol?

The SFTP communication channel or port is the same as SSH (socket 22) and implements two ways of authentication: through a regular username and password as FTP does, or through the creation of a public key and another private, just like SSH works, although the latter supports both modes.

The problem with authentication or connection via username and password is that it represents a greater security risk, since anyone who obtains this data can access your information.

While by way of generating two keys, the public key on the server and the private key on your computer, both keys are validated and this is what allows the connection to be established.

Therefore, the first step is to create both keys through a software or command that is adapted to the operating system of your local computer.

Then, you must establish a connection with the server you want to access, transfer the file or files and close the session. You can do all of this both via commands and through the use of programs called FTP Clients such as Filezilla, WinSCP and SmartFTP, among others.

Although you can connect to the server with file transfer software that allows you to use SFTP, below you will learn the most common commands so that you can do it directly from the shell or command window of your operating system.

 

How to Connect to Your Hosting Using SFTP?

To establish communication between your computer and the server, you will have to write one of the following instructions in the command window of your operating system:

●       sftp user@server _ipaddress

●       sftp user@remotehost _domainname

In these commands you must replace the word user with the username of the SFTP account, and server_ipaddress with the IP address of your server or remotehost_domainname with the name of the remote server.

If the connection has been successfully established, you will see this prompt in the command window:

●       sftp>

If there is no error, this should exit very quickly.

How to Perform File Transfer Using SFTP?
If you want to know in which directory you are positioned both remotely and locally, you must use the pwd (remote directory) and lpwd (local directory) commands:

●       sftp>pwd

●       Remote directory: /RemoteDirectory

●       sftp> lpwd

●       Local directory: /LocalDirectory

To transfer a file from the remote directory to the directory on your local computer, you must execute the following statement and press the TAB key:

●       get filename.extension (TAB)

Example:

●       get index.php (TAB)

To transfer files from your computer to the remote server you must execute the following instruction:

●       put filename.extension (TAB)

Example:

●       put audio.php (TAB)

You can also perform bulk downloads or uploads via the mget and mput commands.

To download:

●       mget filename.*(TAB)

●       mget*.extension (TAB)

●       mget*.*(TAB)

Thus, the first downloads all files with the same extension, the second all files with the same name, and the third all files.

If you want to bulk upload:

●       mput filename.*(TAB)

●       put *.extension (TAB)

●       put*.*(TAB)

 

Main SFTP Commands

There are other commands that will be very helpful to work with this secure communication protocol. Among them can be highlighted:

●       lsIt is used to generate a list of files found in the remote directory.

●       lls generates a list of the files found in the local directory.

●       CD if you want to change directory on your remote computer.

●       lcdif you want to change directory on your local machine.

●       mkdirto create a directory on the remote server.

●       lmkdirto create the directory on the local machine.

●       rmdirto remove a directory on the remote server.

●       rm to delete a file.

●       renameto rename a file.

●       quitto close the SFTP session and ! to return to the regular commands of your operating system.

 

Conclusions

Data networks use communication mechanisms that allow computers to interpret the information that travels through them, called protocols. One of these protocols is FTP, which has been in charge of file transfers for years.

But, due to the multiple security problems that arise on the Internet, it was necessary to implement some other protocols that provide greater advantages of confidentiality to users.

Among many, SFTP or SHELL File Transfer Protocol emerged, which arises from the well-known SSH but which implements the functionality of FTP. To use it, it is necessary to make the connection from the command window of your operating system, as well as create the public and private keys.

Then, you will have to establish the connection between the server and the local computer, carry out the respective file transfers and finally close the session. For this and more, a series of commands or software called FTP clients are used.

If you liked this information, would you let me know? Thanks for your time ;-)

Buscar