SSH change port to 2021

Hi , ive installed ubuntu and doing some security stuff.

non root- done
ssh key - done
fail2ban - done
now im stuck at changing the port.

these are my steps.

sudo nano /etc/ssh/sshd_config , edited the port >
reboot server.

ssh -p 2021 [email protected]>
i receive error : ssh: connect to host myip port 2021: Connection refused

strange part is that i check the status it shows port 2021 active

[email protected]:~$ sudo netstat -tulpn |grep sshd>

tcp 0 0* LISTEN 1013/sshd: /usr/sbi
tcp6 0 0 :::2021 :::* LISTEN 1013/sshd: /usr/sbi>

so i open the firewall

sudo iptables -A INPUT -p tcp --dport 2021 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --dport 2021 -m state --state ESTABLISHED -j ACCEPT>

still cant go in. what am i doing wrong .?

4 Replies

Did you restart the firewall?

Also, don't forget to close port 22.

-- sw


Is rebooting the whole linode sufficient ?

  1. yes, thanks for this reminder.


this is my ufw status

[email protected]:~# ufw status
Status: active

To Action From
-- ------ ----
2021 ALLOW Anywhere
2021 (v6) ALLOW Anywhere (v6)

Re-booting should have been sufficient. If it's not, then something else is not right… your sshd configuration perhaps. The config for the daemon is in /etc/ssh/sshd_configNOT /etc/ssh/ssh_config…that's for the client.

-- sw


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct