This is a beginner’s guide shows how to install and setup SSH server and client in Ubuntu 21.04 Hirsute Hippo and Ubuntu 21.10 Impish Indri.
SSH, also known as Secure Shell or Secure Socket Shell, is one of the most have network services for securely remote login, file transfer. Ubuntu includes OpenSSH is its universe repositories. It’s the open-source version of the SSH tools used by administrators of Linux and other non-Windows.
Install OpenSSH in Ubuntu:
Ubuntu ships with the SSH client out-of-the-box. To install SSH server along with SFTP access from remote machines, open
terminal and run command:
sudo apt install ssh
Start, restart, stop SSH service:
After installed the network services, it should run silently in the background. To check out the status, run command:
systemctl status sshd.service
You can replace
status in the code with reload, restart, start, or stop to do relevant actions. For instance, the command below will reload the configuration:
systemctl reload sshd.service
Change SSH server configuration:
To configure the SSH server rules, e.g., listening port, allowed users, etc, open
terminal and run command to edit the /etc/ssh/sshd_config file with nano text editor.
sudo nano /etc/ssh/sshd_config
When the file opens, you can do:
- Change listening port by removing # at the beginning of line “#Port 22” and changing the number.
- Add user authentication by
AllowUsers username1 username2 usernameX. By default, all users is allowed to login. If specified, only users in the list can login.
- Specifiy the local addresses ssh should listen on via ListenAddress.
And there are many more other configuration rules available. You can get the documentation by running command:
After saving the changes via Ctrl+X keyboard shortcut, follow with Y, and Enter, remember to reload the SSH service by running the previous systemctl command.