I want to change the ssh port from 22 to 2800. I tried to change the /etc/ssh/ssh_config
and removed the # from Port line and changed the number to 2800. after trigger the command: service ssh restart
The connection continued. When I tried to connect from the port 2800, It refused.
The Content of /etc/ssh/ssh_config
is: Removed commented lines
Host *
Port 2800
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
The command service ssh status
gives the following output:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2017-09-22 20:31:45 IRST; 1s ago
Main PID: 1825 (sshd)
Tasks: 1
Memory: 724.0K
CPU: 5ms
CGroup: /system.slice/ssh.service
└─1825 /usr/sbin/sshd -D
Sep 22 20:31:45 GoodMind systemd[1]: Starting OpenBSD Secure Shell server...
Sep 22 20:31:45 GoodMind sshd[1825]: Server listening on 0.0.0.0 port 22.
Sep 22 20:31:45 GoodMind sshd[1825]: Server listening on :: port 22.
Sep 22 20:31:45 GoodMind systemd[1]: Started OpenBSD Secure Shell server.
I tried other ports too. But still it has the same status. What do I do wrong?
Change the port not in the file:
/etc/ssh/ssh_config
but in/etc/ssh/sshd_config
(file withd
letter, meaning "daemon")Just edit this change and change uncomment and update the line
Don't forget to restart your service as you done it with
Your settings are correct but you changed them in the wrong config file. It should be
/etc/ssh/sshd_config
and you might want to restart the SSH service and open the new port your SSH Server is listening on.To do this, run the following commands:
sudo service ssh restart
orsudo systemctl restart sshd.service
sudo iptables -I INPUT -p tcp --dport 2800 -j ACCEPT
.This should be all you need to accept connections on port
2800
. You can also check what ports your machine is listening on withnetstat -lt4
and you should see a line similar toLet me know if it works for you!