How to Install SSH Server on Ubuntu 22.04
Abstract: etc. SSH server is not installed on Ubuntu 22.04 by default. Howeversudo ufw reload Access Ubuntu 22.04 via SSH You can connect to your system via SSH
SSH Server is a server-side software program that uses a secure shell to accept the connections from the client system. It is an alternative for Telnet and other protocols such as rlogin, rsh, etc.
SSH server is not installed on Ubuntu 22.04 by default. However, you may want to enable it after the fresh installation of the OS for connecting your Ubuntu system from external machines.
In this post, we will see how to install SSH Server on Ubuntu 22.04.
PrerequisitesTo install the SSH server and enable it on Ubuntu 22.04, you need to log in as a root user or a user with sudo privileges to execute commands in the next section.
Install SSH Server on Ubuntu 22.04Open up a terminal and then execute the below command to update the repository index.
sudo apt update
Then, install the SSH Server package using the apt
command.
sudo apt install -y openssh-serverEnable SSH Server on Ubuntu 22.04
By now, the SSH server service should start automatically. You can verify the SSH server service status by running the following command.
sudo systemctl status sshSSH Server Service Status on Ubuntu 22.04
The above screenshot confirms that the SSH service is up and running.
Allow SSH in FirewallSometimes, you may need to allow SSH connections coming from client systems in the firewall. So, use the below command to create a rule for allowing SSH connections from external machines.
sudo ufw allow ssh sudo ufw enable sudo ufw reloadAccess Ubuntu 22.04 via SSH
You can connect to your system via SSH using putty from Windows or built-in SSH clients from Linux or macOS.
ssh user_name@ip_addressEnable SSH Root Login on Ubuntu 22.04
By default, you will not be able to log in as the root user via SSH for security reasons. However, you can enable root login by editing the SSH configuration file at your own RISK.
Update the SSH configuration with the below command.
echo "PermitRootLogin Yes" | sudo tee -a /etc/ssh/sshd_config
Then, restart the SSH service to read the new configuration.
sudo systemctl restart ssh
Now, you should be able to login directly as the root via ssh.
Disable SSH Service on Ubuntu 22.04If you want to disable SSH on your system, you can stop and disable the SSH service so that it doesn’t start on a system reboot.
sudo systemctl stop ssh sudo systemctl disable sshConclusion
That’s All. I hope you have learned how to install SSH Server on Ubuntu 22.04. You can now perform management activities over the terminal. Additionally, you can set up SSH Key-based authentication that lets you log in to your system without entering a password.