How to change default SSH port?

Everyone knows 22 is the default SSH port. So it’s always good to change this default port and set it to something unguessable. Please follow the below steps.

Here we are going to change the port to 4242. Edit the main SSH configuration file.

vi /etc/ssh/sshd_config

You can find the below line.

#Port 22

Change it as below.

Port 4242

Restart SSH to update the changes.

/etc/init.d/sshd restart

That’s it!! You have changed the SSH port to 4242. :)

To login as “sshusr” from a remote Linux machine you can run the below command.

ssh [email protected]/Hostname -p 4242

 

Was this answer helpful?

 Print this Article

Also Read

How to Prevent DDOS with CSF

You just need to configure two csf directives, thats it. The two directives are PORTFLOOD and...

25 Most Frequently Used Linux IPTables Rules Examples

In the below examples we are using ETH0 as network interface, however if you are using our...

Installing Rkhunter (Rootkit Hunter) in RHEL, CentOS and Fedora

Rkhunter (Rootkit Hunter) is an open source Unix/Linux based scanner tool for Linux systems...

How to Prevent Symlink Attacks

ad Impact of Symlink - Suppose you own a small hosting company with a Linux Box, & 1337...

How to secure /tmp and /var/tmp

Secure /tmp Edit /etc/fstab by typing the command nano -w /etc/fstab Paste the following...