How to Change SFTP Port in Linux

Safe File Transfer Protocol is what SFTP stands for. Secure Shell (SSH), which is used to implement this protocol, is more secure and protects against vulnerabilities than FTP. SFTP gives you a safe way to talk to a remote computer over an unknown and potentially dangerous network. To transfer files, SFTP uses a client-server architecture. You can also Change SFTP Port in Linux.

It also lets you do different things with remote files and start file transfers over again. You can use SFTP instead of the older FTP protocol. It does everything that FTP does, but the connection is safer. Secure Shell, or SSH, is a network protocol that lets users connect to a server from a distance. It also makes communication between a client and a private server more secure by encrypting it.

Ports, which are also known as channels, are an important part of sending data over the internet. Different programmes use different ports to talk to servers over the internet. There have been between 1024 and 65535 of these ports. In this post, we’ll talk about how to change SFTP ports in Linux.

How to Change SFTP Port in Linux

How to Change SFTP Port in Linux

Choose a New Port Number

In Linux, port numbers lower than 1024 are only used for well-known services, and only root can bind them. To avoid port allocation problems, you can use an SSH service port in the range of 1–1024, but it is recommended that you use a port higher than 1024. In this case, you can change the SFTP/SSH port to 4422, but you can use any port you want.

Adjust Firewall

Before you can change the SFTP/SSH port, you must first open the new port in your firewall.

  • If you are using the UFW firewall that comes with Ubuntu, use the following command to open the port:
sudo ufw allow 4422/tcp
  • CentOS comes with FirewallD as the tool for managing firewalls. Enter the following commands to open the port:
sudo firewall-cmd --permanent --zone=public --add-port=4422/tcp
sudo firewall-cmd --reload
  • Users using CentOS must also change their SELinux rules to accept the new SSH port:
sudo semanage port -a -t ssh_port_t -p tcp 4422
  • If you’re using another Linux distribution with iptables, you can open the new port by typing the following command:
sudo iptables -A INPUT -p tcp --dport 4422 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT

Configure SFTP/SSH

  • The /etc/ssh/sshd config file contains the SSH server configuration. Use your text editor to open the file:
sudo vim /etc/ssh/sshd_config
  • Find a line that begins with “Port 22.” Most of the time, the hash sign (#) is used to remove a line. Remove the # and put your new SSH port number in its place:
Port 4422
  • Be very careful when changing the configuration file. If the settings are wrong, the SSH service might not be able to start. Save the file and restart the SSH service for the changes to take place:
sudo systemctl restart ssh
  • The SSH service in CentOS is called sshd:
sudo systemctl restart sshd
  • Make sure the SSH daemon is listening on the new port by checking the following:
ss -an | grep 4422

Use the New SFTP Port

  • To change the port number, use the sftp command with the -P option and the new port number:
sftp -P 4422 username@remote_host_or_ip
  • Simply input the new port in the client interface if you’re using a GUI SFTP client.

What is SFTP Port in Linux?

SFTP, or SSH File Transfer Protocol, is a protocol that encrypts the connection between two hosts when files are being sent between them. It lets the user do different things with files that are far away and also restart file transfers. It works the same way that FTP protocols do, but the connection is more secure.

By default, SFTP uses port 22, while the FTP protocol uses port 21. One difference between these two protocols is that SFTP only uses one port to send and receive files, while FTP uses multiple ports in a more flexible way. Both the server and the client decide automatically on which channels to use.

So using FTP protocols poses some security risks because this is where attackers can get in. SFTP (SSH File Transfer Protocol) is a file transfer protocol built on the SSH (Secure Shell) transport layer. It is used to move large amounts of data securely over the internet.

SFTP uses SSH to set up a secure, authenticated connection and give organisations a higher level of protection for file transfers. It uses the authentication and encryption features of SSH to keep files safe while they are being sent.

FAQ

What are the benefits of using SFTP over other file transfer protocols?

SFTP is better than other file transfer protocols because data can be sent securely and encrypted, the client and server can be verified, and data can be sent over networks that are not secure, such as the internet.

Can SFTP use port 443?

HTTP port 443 is a new protocol that fixes most of the problems with SFTP that made it hard to use for many small transfers. SFTP uses a stateful control connection that keeps a current working directory. Each transfer needs a second connection through which the actual data is sent.

How do I check my SFTP connection?

To test the SFTP connection and the web server, you use a test file. Use an SFTP tool for the command line that comes from a third-party source. For example, this test works well with PuTTY SFTP client (PSFTP). Note: You can download several PuTTY programmes, but only PSFTP works for this test.

What port is FTP and SFTP?

FTP lets connections come in on port 21, while SFTP lets connections come in on port 22. FTP doesn’t offer encryption, but SFTP does so that the data can be sent securely. The FTP uses SSH architecture, while Client-server architecture is used by FTP.

What is port number 20 and 21 in SFTP?

The control channel goes through port 21, and the data channel goes through port 20. Find out how to use these two channels. You may already know that FTP commands use TCP port 21 when they travel over the wire. You may also know that by default, port 20 is set up as the FTP data channel.

Editorial Staff
Editorial Staffhttps://www.bollyinside.com
The Bollyinside editorial staff is made up of tech experts with more than 10 years of experience Led by Sumit Chauhan. We started in 2014 and now Bollyinside is a leading tech resource, offering everything from product reviews and tech guides to marketing tips. Think of us as your go-to tech encyclopedia!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related Articles

Best Budget Apps: take control of your finances

It was hard for me to keep track of my money before because I have many plans for how much...
Read more
My approach to managing my funds has been completely transformed by the use of personal finance Apps. Because of their...
Because the internet changes so quickly, I need to make sure that the app on my Android phone keeps me...
This is because businesses need strong tools to keep an eye on their infrastructure because they count on technology more...
It can get pretty busy in college with classes, chores, clubs, and making friends. Calendar apps have really helped me...
I know that the development tools for smart contracts are important for making blockchain apps and getting them to users....