• Hello and welcome! Register to enjoy full access and benefits:

    • Advertise in the Marketplace section for free.
    • Get more visibility with a signature link.
    • Company/website listings.
    • Ask & answer queries.
    • Much more...

    Register here or log in if you're already a member.

What is Secure File Transfer Protocol (SFTP) and Its Usage?

admino

Administrator
Staff member
Messages
89
Reaction score
1
Points
13
Balance
$3.2USD
Curious about SFTP and how it works? Curious about how SFTP affects your company's performance in a positive way? Curious about the level of security offered? Do not worry because after reading this post you will be able to eliminate all your curiosity!

what-is-sftp-and-its-usage.jpg

At first, the SFTP is such a protocol used to transfer files. What makes it different from other similar transferring protocol is that the protocol uses SSH to make any transferred commands and data safe. The protocol is needed to secure the transferred files especially when they’re not encrypted. The unencrypted data are vulnerable to some classic problems like interference, falsifications and eavesdropping. That’s why you need to find another more secure protocol, the SFTP!


For you who are accustomed to using FTP, you’re suggested to use the protocol only on very limited cases or trusted networks. Don’t risk all just because you’re too lazy to learn something more secure such as SFTP. Because of SFTP uses SSH protocol in its work, you can run almost all authentication methods available as are presented by SSH. That means, if you can use SSH, you can also use SFTP. As simple as that!

The brief description of FTP and sFTP

Firstly, you need to know what the FTP is and then you can understand well why you need to “change it” into SFTP. FTP is the most used file transfer protocol in the network. Generally, when we connect to an FTP server the connection is made directly between client and server and the data travels without any protection. Although in a local environment this can have certain advantages, when we access from other networks or through the Internet it is possible that depending on the type of data that we are going to transfer we must do it through an additional layer of security that prevents intermediate connections to be made with the content of the packages.

SFTP is another variant of the FTP protocol for secure data transmission. It is commonly used with the SSH protocol to provide such secure file transfer, although it can also be used with other secure data transfer protocols.


Advantages of SFTP​

  • It has standards that perfectly define most operations.
  • It uses only one connection, without the need to establish additional connections.
  • Connection always assured.
  • Directories readable by the machine.
  • It includes authorization operations, attributes, permissions, file locking and more additional functions.

Disadvantages of SFTP​

  • The communication is done in binary. It is very complicated to understand for a user.
  • SSH keys are complicated to configure, validate and manage.
  • It can generate some problems between applications because it does not have a defined standard.
  • Does not allow server to server copy.
  • Does not allow recursive deletion of directories.
  • Some systems are not compatible with SSH / SFTP

How to use SFTP?​

When you’re really sure to use SFTP, you can go to the following steps! Watch the steps carefully as it needs very specific commands. Just keep reading on…

Let's move on to the first step. At first, you need to make sure you’re able to do the beginning SSH access test. You can try doing SSH access test with the following command:

ssh username @ remote_hostname_or_IP

If it works, you can exit by typing:

We can establish an SSH connection then open an SFTP session using that connection by issuing the following command:
sftp username @ remote_hostname_or_IP

If it’s been connected remotely, the indicator will change to an SFTP symbol.


Navigating with SFTP

In the first place, we are going to orientate ourselves by finding out what directory we are in at the moment in the remote system:

Remote working directory: / home / demouser


We can see the contents of the current directory of the remote system with another familiar command:

We can access another directory with the command:

And also go back to the previous directory:


File transfer with SFTP

Transferring remote files to the local system


If we want to download a file from the remote server to the folder from which we’re connected by SFTP, we must execute the following command:
get remoteFile

The "get" command also has some option flags. For example, we can copy a directory and all its contents by specifying the recursive option:
get -r someDirectory

We can utilize the SFTP to maintain the appropriate permissions and access times by using the "-P" or the "-p" flag:
get -Pr someDirectory

Transferring local files to the remote system

File transfer with the remote system is carried out with the same ease, but with the appropriate command named "put":
put localFile

The same functions that work with "get" apply to "put". So to copy a whole local directory, we can use:
put -r localDirectory

Reviewing available space

Confused of how to check if there’s enough space to complete the transfers? You can use this familiar tool; df command. For you who haven’t known this yet, it’s a similar to command line version.

Output of df -h
Filesystem Size Used Avail Use% Mounted on
/ dev / sda4 40G 1.8G 36G 5% /
tmpfs 16G 0 16G 0% / dev / shm
/ dev / sda7 2.2T 797G 1.3T 39% / home
/ dev / sda5 15G 170M 14G 2% / tmp
/ dev / sda3 60G 12G 45G 22% / usr
/ dev / sda2 197G 33G 155G 18% / var

How to get out of SFTP

To close the SFTP session, type:

Although SFTP is a simple tool, it is very useful for managing servers and transferring files between them. If you are used to using FTP or SCP to achieve your transfers, SFTP is a good way to take advantage of the strengths of both. Although it is not appropriate for each situation, it is a flexible tool to have as backup option. Now, you can take this post as your inspiration. Hope this helps you. Good luck!
 
Top