Ubuntu SSH Configuration: Complete Guide
The steps to configuring SSH in Ubuntu are as follows:
- To verify that OpenSSH is installed, type the following command in the terminal to check if OpenSSH is already installed:
sudo apt list --installed | grep openssh-server
- If OpenSSH is not installed, you can use the following command to install it:
sudo apt update
sudo apt install openssh-server
- Configure SSH service: To edit the SSH configuration file, you can use the following command to edit the OpenSSH configuration file:
sudo nano /etc/ssh/sshd_config
In the configuration file, you can specify the SSH port, allowed users, and configure key authentication.
- Restart SSH service: After making changes to the configuration file, it is necessary to restart the SSH service in order for the changes to take effect. You can use the following command to restart the SSH service:
sudo systemctl restart sshd
- Firewall Configuration: If the firewall is enabled on the system, make sure that the SSH port is open. You can use the following command to open the SSH port (default is 22):
sudo ufw allow ssh
- To confirm that the SSH service is started, you can use the following command to check if the SSH service has been started:
sudo systemctl status sshd
Once the setup is complete, you can connect to the Ubuntu server using an SSH client.