How to do it...

To use SSH, you can use freely available software called OpenSSH. Once the software is installed, it can be used by the ssh command. We will look at how to use this tool in detail:

  1. If OpenSSH server is not already installed, it can be installed using the following command:
    sudo apt-get install openssh-server

  1. Next, we need to install the client version of the software:
    sudo apt-get install openssh-client

  1. For the latest versions, the SSH service starts running as soon as the software is installed. If it is not running by default, we can start the service by using the command:
    sudo service ssh start  

  1. Now, to log in to the server from any other system using SSH, you can use the following command:
    ssh remote_ip_address

Here, remote_ip_address refers to the IP address of the server system. Also, this command assumes that the username on the client machine is the same as on the server machine:

If we want to log in for a different user, the command will be as follows:

    ssh username@remote_ip_address

  1. Next, we need to configure SSH to use it as per our requirements. The main configuration file for sshd in Ubuntu is located at /etc/ssh/sshd_config. Before making any changes to the original version of this file, create a backup using the following command:
    sudo cp /etc/ssh/sshd_config{,.bak}

The configuration file defines the default settings for SSH on the server system.

  1. Opening the file in a text editor, we can see that the default port declaration on which the sshd server listens for the incoming connections is 22. We can change this to any non-standard port to secure the server from random port scans, thus making it more secure. Suppose we change the port to 888, then next time the client wants to connect to the SSH server, the command will be as follows:
    ssh -p port_numberremote_ip_address

As you can see, when you run the command without specifying the port number, the connection is refused. When you mention the correct port number, the connection is established.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.150.59