How to install and enable Ubuntu SSH
It doesn’t matter if you didn’t enable the default Ubuntu SSH server OpenSSH during the installation, this can always be done later. You can customize the Ubuntu SSH daemon configuration once the security feature has been installed through the terminal.
Step by step to installing the Ubuntu SSH server
You will need SSH (Secure Shell) for secure remote access to your own computer or server. There are three important aspects in the security procedure which will ensure remote access:
- Authenticating the remote terminal ensures that the wrong contact person (whether client or server) is not contacted.
- Encrypting the data transmission prevents unauthorized persons from reading any information.
- Ensuring data integrity makes transferred data tamper-proof.
Linux distributions such as Ubuntu have relied on the open source suite OpenSSH for SSH and secure file transfer using SCP or SFTP for years now.
OpenSSH is disabled by default when you reinstall Ubuntu, meaning you must enable the service yourself. We’ll outline in this article how to go about this exactly and which configuration options are available to you after enabling the Ubuntu SSH server.
You’ll get a chance to enable SSH as part of the installation process if you use the Ubuntu Server Edition to set up an Ubuntu Server.
Step 1: How do I enable the terminal?
The terminal, i.e., the command line tool in the Linux distribution will be required to install or enable the SSH in Ubuntu though the “install” option. Just open the handy administration tool to begin. The easiest way to do this by using the key combination [Ctrl] + [Alt] + [t].
Alternatively, you can start the terminal from the “Show applications” menu and searching “Terminal” using the search function.
Step 2: How do I install Ubuntu SSH?
You can install OpenSSH in the command line tool using the Ubuntu “install” command for SSH. The command is as follows:
sudo apt install openssh-server
Enter your password and confirm by pressing Enter which will start the installation of Ubuntu SSH immediately.
Step 3: How do I check the status and enable the Ubuntu SSH server?
Once the installation is complete, you can use the following command to check whether the SSH daemon is running as desired:
sudo systemctl status ssh
You should see the entry “active (running)” in the command output when Ubuntu SSH is running. SSH should also be available at every new system start, meaning the entry “vendor preset: enabled” should also be displayed in the “Loaded” line.
You can enter two additional commands if SSH is still inactive and the automatic start on reboot is not activated:
sudo systemctl enable ssh
sudo systemctl start ssh
Press “q” if you want to exit the SSH status and return to the command line input.
Step 4: How do I open the SSH port?
The network protocol port (TCP port 22) must be enabled to connect to your Ubuntu system through SSH from anywhere. This will allow you to successfully establish a remote connection with SSH clients like PuTTy.
Ubuntu has its own configuration program for its native firewall, UFW. An appropriate rule must be set up for this program for SSH communication so the port remains open for incoming and outgoing data:
sudo ufw allow ssh
A closed port is not the only cause of issues with SSH connections. There are several other possible problems which can get in the way of establishing secure SSH connections. We’ll tell you how to resolve SSH errors in the Digital Guide.
Step 5: How do I configure the Ubuntu SSH server?
The basic configuration of OpenSSH is suitable for secure remote connections to your Ubuntu system. You could still customize the default settings, such as choosing a different port for communication, specifying an internet protocol version, or disabling TCP forwarding.
The central configuration file for the Ubuntu SSH package is the sshd_config file. Open this file with the text editor (in this case, nano) of your choice to make any changes:
sudo nano /etc/ssh/sshd_config
Customize the config contents as you wish and save the changes before closing. Then restart OpenSSH to apply the adjustments:
sudo service ssh restart
Setting up SSH is worth it if you plan to use an Ubuntu FTP server. This will offer the secure FTP variant SFTP which was mentioned earlier.