Do you already know about SFTP? SFTP is the same as SSH protocol. SFTP (SSH File Transfer Protocol) is a secure file transfer protocol. It runs over the SSH protocol. It supports full SSH security and authentication functionality. When compared, this SFTP can be compared again with FTP (File Transfer Protocol).
Before reading further, for those of you who want to know more about Netdata, you can contact us directly via the link below.
How about a complete explanation of SFTP? And what is the difference between SFTP and FTP? How to use? Let’s see!
Table of Contents
SFTP explanation
As explained above, SFTP is a secure file transfer over the SSH protocol. Compared to FTP, SFTP has largely replaced the old FTP as a file transfer protocol, and is rapidly replacing FTP/S.
SFTP also provides all the functionality that this protocol offers, but is more secure and more reliable, with easier configuration. There’s basically no reason to use the old protocol anymore.
Benefits of Using SFTP
SFTP also protects against password sniffing and man-in-the-middle attacks. It protects data integrity using encryption and cryptographic hash functions, and authenticates servers and users.
Any company that does business online or with the help of a computer to move data will benefit from a hosted SFTP service. The SFTP solution lets you share files securely via the SSH File Transfer Protocol plus the accessibility and features that keep your business going.
Here are some of the advantages of using SFTP as a service over setting up and maintaining an on-premises server.
- No Hardware Required
- Reduce Business Expenses
- Accessibility
- Data security
- Convenient File Management
- Scalability
- Disaster Recovery & Compliance
Difference between FTP and SFTP
What is the difference between SFTP and FTP? This is a good question. Therefore, we will discuss FTP first.
When compared technologically, of course, SFTP is much better than FTP. FTP is a traditional file transfer protocol. This is a basic way of using the Internet to share files.
Unlike SFTP which is an alternative to FTP which also lets you transfer files, but adds a layer of security to the process.
So, SFTP is the best choice because it uses a better security system than FTP.
How to Use SFTP
To be able to use SFTP, there are three ways that are commonly used, namely by using cPanel and also VPS. Apart from that how do I use SFTP to use it as it should i.e. for data transfer?
How to Use SFTP in cPanel
Note that you cannot connect an FTP account to an SFTP account.
An SFTP client usually requires the following information to connect to the server, including:
- Hostname: The server’s hostname (for example, hostname.example.com).
- SSH port number: The port number that sshd is listening on (eg 22).
- Security: Whether the client combines FTP and SFTP functionality.
- Username: The SSH username the client uses to connect to the server. Username can be a valid cPanel account username or root user.
- Password: SSH user password.
- Private Key: The SSH user’s private key. This is the absolute path to the private key on your local machine (for example, c:\data\id_dsa).
cPanel users can generate and download private keys via the cPanel SSH Access interface (cPanel -> Home -> Security -> SSH Access).
How to Use SFTP on a VPS
If you have created users on your VPS using the adduser or useradd commands, and you are able to connect to your SSH terminal, using them you can use those credentials to login to your VPS using SFTP.
If you want to allow users to connect to your VPS using SFTP then you can simply use the command below:
adduser <username>
This command will ask you to enter a password for it and some information. You just enter your password and press Enter to another question to skip it.
The easiest way to connect to your VPS using SFTP is to use Filezilla. Filezilla comes with SFTP support by default.
To connect to your VPS using SFTP with Filezilla, follow these steps:
- Enter your VPS IP in the Host field
- Enter the username of the user you have created in the Username field.
- Enter the password for the user you created in the Password field.
- Enter your SSH port in the Port field. It is 22 by default if you don’t change it.
- Click the Quickconnect button.
- Click OK when a popup appears showing a warning about an unknown host key.
How to Use SFTP for Data Transfer
For example, we will use how to remote files from the server to the local system. Here’s how.
To get started, let’s check which local and remote working directories we are using. To do this, we’ll use this SFTP command:
sftp> lpwd
local directory: /LocalDirectory
sftp> pwd
remote directory: /RemoteDirectory
Now, let’s see how to transfer files from remote server to your local machine using the get command. Here’s the basic syntax of the get command:
get /RemoteDirectory/filename.txt
For example, to copy the /etc/xinetd.conf file from a remote server to your local machine, you would use:
get /etc/xinetd.conf
Once the download is complete, you can now find that the xinetd.conf file is in your local machine’s /user/home directory.
To download multiple files with SFTP, use the mget command. To download all the files in a directory called /etc that have the .conf extension to your current working directory, you would use the following command:
mget /etc/*.conf
After downloading, you can find all *.conf files in your local machine’s /user/home directory.
Basic SFTP Commands
To be able to configure SFTP, there are several basic commands that can be used, including:
Check Disc Information
To be able to check disk information, the command is as follows:
df
Buat Direktori
To create a directory on a remote server, the command used is:
mkdir directory_name
Rename File
If you want to rename the file, here is the command:
rename old_filenamenew_filename
Delete Files
To be able to delete files on a remote server, the command used is:
rm file_name
Change File Permissions
To be able to change file permissions, you can use the chmod command.
chmod 644 file_name
Change File Owner
If you want to change file permissions, you can do this by:
chown user_id file_name
Change Group File Owner
Finally, if you want to change the owner of a file group, you can use the command:
chgrp group_id file_name
NetData is a company that provides technology-based services with the best service and quality, if you are interested in us you can contact us directly via this link or via our contact form here.