How do I change Fedora 25 SSH port?
Steps already tried:
1) In /etc/ssh/ssh_config I have uncommented the line consisting of # Port 22 and change 22 to a a random one, e.g.: 50687. Additionally I uncommented the # Host * line.
2) I tried creating a new line consisting of:
Port 50687
at the bottom of the file.
3) /etc/ssh/ssh_config has the note:
# To modify the system-wide ssh configuration, create a *.conf file under
# /etc/ssh/ssh_config.d/ which will be automatically included below
Include /etc/ssh/ssh_config.d/*.conf
The only file in .../ssh_config.d/ is 05-redhat.conf
Again I tried uncommenting (and modifying) the # Host 22* line and creating a new line at the bottom of the.
4) I created a file 06-myfile.conf conisisting only of either:
Port 50687
or
Host *
Port 50687
After completing any of these steps I have issued:
sudo systemctl restart sshd.service
and tried to connect (via port 50687) and/or:
sudo systemctl status sshd.service
[sudo] password for spaceman:
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2017-04-25 14:47:15 BST; 23min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 5967 (sshd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/sshd.service
└─5967 /usr/sbin/sshd -D
Apr 25 14:47:15 nas systemd[1]: Starting OpenSSH server daemon...
Apr 25 14:47:15 nas sshd[5967]: Server listening on 0.0.0.0 port 22.
Apr 25 14:47:15 nas sshd[5967]: Server listening on :: port 22.
Apr 25 14:47:15 nas systemd[1]: Started OpenSSH server daemon.
What utterly n00bish error am I making?
You
systemctl status ...
was 23 minutes old. Are you sure your sshd service restarted successfully?Check this piece of documentation in regards to SELinux and ports.
Verify settings with:
semanage port -l | grep ssh
nmap localhost
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00090s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 989 closed ports
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
80/tcp open http
111/tcp open rpcbind
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
3306/tcp open mysql
8200/tcp open trivnet1
9090/tcp open zeus-admin
10000/tcp open snet-sensor-mgmt
So, have you tried to modify the port context, and then reloaded the service?
Sorry, one of my answers has gone walkabout. SELinux is not enabled and I have firewalld disabled too at this point. I'm not sure what changing the port content means? The 23 mins delay in outputting the status of sshd.service is merely the output I copied for the post, the first one I issue seconds after the restart (reload next time).
In which config file did you modify the port ? You mentioned /etc/ssh/ssh_config (so the client) and you restarted the server. As pointed by Florian, you should edit /etc/ssh/sshd_config.