Install SSH Server in Ubuntu

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.

  • Start the console via the menu or holding down a combination of Ctrl + Alt + T.
  • Immediately start the downloading of the server files from the official repository. For this you will need to enter sudo apt install openssh-serverand then press Enter.
  • As we use the prefix sudo (execute actions on behalf of superuser), you’ll need to enter the password from your account. Note that characters in the input are not displayed.
  • You will be notified about downloading a certain volume of the archives, confirm the action by selecting option D.
  • By default, the client installed with the server, but not the superfluous will check by trying to install it again using 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:

  • Launch the console and mount it sudo systemctl enable sshdto add a server to the startup Ubuntu if suddenly this did not happen automatically after installation.
  • If you do not want the tool launched along with the OS, remove it from startup by typing sudo systemctl disable sshd.
  • Now let’s check how you are connecting to the local computer. Use the command ssh localhost (the localhost address of your local PC).
  • Confirm continue the connection by selecting the option yes.
  • In case of successful download you will get about this information, as you can see in the following screenshot. You need to check the connection address 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.
  • With each new connection you will need to confirm.
  • 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.

  • Priority save a backup copy of the configuration file, in which case refer to it or to reset the SSH. In the console paste the command sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original.
  • Then the second: sudo chmod a-w /etc/ssh/sshd_config.original.
  • Run the settings file is executed via 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.
  • Here you can change the port used, it’s always better to be done to ensure the security of the connection can then be disconnected login as root (PermitRootLogin) and included activation key (PubkeyAuthentication). After editing is complete, press the key : (Shift + ; on Latin layout) and add the letter wto save the changes.
  • The output from a file is carried out in the same way, only instead of w is used q.
  • Don’t forget to restart the server by typing sudo systemctl restart ssh.
  • After changing the active port, it is necessary to fix in the client. This is done by specifying ssh -p 2100 localhost, where 2100 — the number replaced by the port.
  • If you have a firewall configured, there also needs to be replaced with: sudo ufw allow 2100.
  • You will receive a notification that all the rules have been updated.
  • 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.

  • Open a console and create a new client key by typing ssh-keygen-t dsaand then assign a name to the file and specify the password for access.
  • After this is saved the public key and create a secret image. On the screen you will see it.
  • You only have to copy the generated file to the second computer to turn off connect using a password. Use the command 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).

    Source: lumpics.ru

    (Visited 36 times, 1 visits today)