This is the new installment of the Linux Basics Series: How to connect via SSH to another system. We are going to teach how to connect to a linux system from another system.
To connect to another system by ssh from a linux system is as simple as having installed the application “openssh-client” and run the command “ssh” as follows:
- ssh user@host: connects with a user to a specific host asking for the password.
- ssh -l user host: connects to a user to a given host asking for the password
- “ssh -i key_file user@host” or “ssh -i key_file -l user host”: connects a user to a given host using the selected key file. To generate a key file from a linux system just run the command “ssh-keygen” and this command will generate a new key file as shown in the picture:
If we do it from windows we must download an application like “putty”, which can be downloaded from https://www.putty.org/. Putty is an application that acts as a SSH client. In the following images you can see how to connect from putty both with username and password.
First of all to connect by password we only have to enter the IP and click on the “open” button. If we want to save the configuration we only have to click on the “save session” button before clicking on the “open” button.
If it is the first time you connect to a node you will only get a warning that you have never connected to that server before.
After this we will be asked for user and password, in this case I have introduced the user “root” but in other systems it can be a different one.
After entering the user and password we are already inside the system and we can enter commands as if we had the remote system in front of us.
If we want to access with a password, we must first generate it (if we have not been provided with a password).
Once generated we save it, we must save the public and private keys by clicking on the “save private key” and “save public key” buttons.
After having included in the file “~/.ssh/authorized_keys” the generated public key, we will be able to access with the key file. This step will be done later in the book. This step should be omitted if the key file has been provided by a provider as it has already been done by itself (both the key generation and including it in the file). The next step is to configure the session to connect by key, to do this just do the following:
In the saved session with the IP, go to the SSH → Auth section in the tree on the left. Then select the private key to use:
Then go to Connection → Data and enter the user in the “auth login username” section.
Finally, we must save the session by clicking on “save session” to save the configuration. Then you can click on the “Open” button to connect to the new configuration and use the key file.
If everything has been configured correctly, by clicking on the “Open” button we will connect directly and we will not be asked for the password.
And this has been all about how to connect by SSH to another linux system from windows and linux.
If you liked the article leave a comment and/or share on your social networks.
See you soon!