SSH is used for secure connection with a computer that allows to remotely control not only through the operating system shell, but also an encrypted channel. Sometimes the users operating system Ubuntu there is a need to put an SSH server on your PC for implementation purposes. So we offer to get acquainted with this process, examining not only the procedure of downloading, but the basic settings.
Install SSH server in Ubuntu
Components of SSH available for download via the official repository, therefore, we shall consider only this method, it is the most stable and reliable, and does not cause difficulties for novice users. The whole process, we broke into steps to make it easier to navigate the instructions. Let’s start from the beginning.
Step 1: Download and install SSH server
To complete the task we will be using “Terminal” using the basic command set. To have additional knowledge or skills not necessary, you will receive a detailed description of each action and all the necessary commands.
sudo apt install openssh-serverand then press Enter.
sudo apt-get install openssh-client.
The SSH server will be available to interact with it immediately after you successfully add all the files in the operating system, but it still should be configured to ensure correct operation. Suggest you read the following steps.
Step 2: Checking server
First, let’s verify that the default settings were applied correctly, and the SSH server responds to basic commands and performs them correctly, so you need to:
sudo systemctl enable sshdto add a server to the startup Ubuntu if suddenly this did not happen automatically after installation.
sudo systemctl disable sshd.
ssh localhost(the localhost address of your local PC).
of 0.0.0.0, which acts as the network default IP for other devices. To do this, type the appropriate command and press Enter.
As you can see, the ssh command used to connect to any computer. If you have a need to connect with another device, just launch the terminal and enter the command format is
ssh [email protected]_address.
Step 3: edit the configuration file
All additional configuration of the SSH Protocol are made through a special configuration file by changing the rows and values. Won’t focus at all points, moreover, most of them are highly individual for each user, we only show the basic steps.
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original.
sudo chmod a-w /etc/ssh/sshd_config.original.
sudo vi /etc/ssh/sshd_config. Immediately after entering it will be launched and you will see its contents as shown in the screenshot below.
wto save the changes.
sudo systemctl restart ssh.
ssh -p 2100 localhost, where 2100 — the number replaced by the port.
sudo ufw allow 2100.
Other parameters you may find yourself reading the official documentation. There are tips on changing all the items to help determine what values to choose for you personally.
Step 4: Adding keys
When you add an SSH key opens the authorization between the two devices without the need to pre-enter the password. The identification process is reconstructed by the algorithm of reading a secret key and a public key.
ssh-keygen-t dsaand then assign a name to the file and specify the password for access.
ssh-copy-id [email protected]where [email protected] — the remote computer name and IP address.
You only have to restart the server and check the correct operation through an open and secret key.
The procedure to install the SSH server and its basic configuration is complete. If you type all the commands correctly, no errors in the execution of a task should arise. In case of any problems with the connection after the settings, try to remove SSH from startup to solve the problem (read about this in Step 2).