in ubuntu 24.04 how to change ssh port to 22022 and disable login, except ssh keys
- User
in ubuntu 24.04 how to change ssh port to 22022 and disable login, except ssh keys
- Assistant
To change the SSH port to 22022 and disable password login except for SSH keys on Ubuntu 24.04, you can follow these steps:
Step 1: Change the SSH Port
-
Open the SSH configuration file: You can use a text editor like or . Here we'll use .
-
- User
systemctl restart sshd Failed to restart sshd.service: Unit sshd.service not found.
- Assistant
If you encounter an error like
Failed to restart sshd.service: Unit sshd.service not found, it's likely that the service is namedsshrather thansshdon your Ubuntu system.You can restart the SSH service with the following command:
bashsudo systemctl restart sshVerifying SSH Service Status
To check the status of the SSH service and confirm that it restarted successfully, you can use:
bashsudo systemctl status sshSummary of Commands
-
Restart SSH service using:
bashsudo systemctl restart ssh -
Check the status of the SSH service using:
bashsudo systemctl status ssh
If everything is functioning correctly, SSH should now be running on port 22022!
-