If you want to get a VPS service, you need to know what SSH access is. The SSH access is necessary to manage your VPS, especially if you don’t use a panel. It’s really simple to use SSH to connect to a remote server. You simply type the IP, username, and password to get full access to your VPS.
Here we discover about SSH and how to use SSH as detail as possible.
What is SSH?
SSH stands for Secure Socket Shell, which is a protocol that gives an administrator access.
When you are using SSH, you can connect to a different computer or a server from a separate location as long as you are still connected to an internet network. SSH is used to encrypt the connection that occurs between your device and the server in a different location.
So, this SSH tutorial would be very useful for you if you want to access to a remote server.
Normally, a Network Administrator and System Administrator use SSH to remotely manage a server. SSH allows the users to execute programs, copy, move, and even delete files on the server without having to visit the physical server directly.
There are two ways of using SSH such as using a key and without a key. Using SSH with a key is more secure as it requires two-way authentication, either from the client or from the server.
How to Use SSH
The following are the steps of how to use SSH starts from the installation on Linux or Windows system. Along with simple guides on how to use SSH with a key or without a key.
1. SSH Installation
Basically, the use of SSH on all operating systems just the same. Only, if you are running Windows operating system, you will need an SSH client application.
SSH Client on Linux
Linux operating systems usually have SSH client application. So, you don’t need to install SSH on Linux. However, if you found out that your Linux operating system has no SSH client application, you can install OpenSSH-client package.
$ sudo apt install openssh-client
Once the OpenSSH-client package has been successfully installed on your Ubuntu Linux, the SSH configuration file is located in /etc/ssh/sshd_config folder.
Install SSH on Windows
If you are using Windows operating system, you need to install the SSH client application. There are several options you can choose from, such as PuTTY, Bitvise, KiTTY, and so on. PuTTY is the most popular SSH client application and the most widely used. You can download PuTTY from www.putty.org.
2. SSH Connection without a Key
SSH Connection without a Private Key on Linux
Step 1 – Open the Terminal program, you can then directly enter your the username and hostname/ipaddress of your server.
$ ssh username@host
Replace the “username” above with the user or the server and replace the “host” with the address or the domain name server.
[cincun@cincun ~]$ ssh firstname.lastname@example.org
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Mar 6 20:57:28 2018 from 22.214.171.124
Step 2 – You will be asked to enter a password. Enter the password for that username. If successful, you will connect to your server.
SSH Connection without a Key on Windows
Step 1 – If you have installed PuTTY on your Windows, you can open it and then enter the server address in the Host Name field.
Step 2 – When the “login as:” window opens, enter the username that is listed on your server as well as the password for that username.
Step 3 – If you enter the credentials correctly, the server terminal will appear and you have successfully connected to the server system.
3. SSH Connection with SSH Key
SSH Key is a component of the SSH that is used to secure connection between two devices using a certain cryptographic technique.
SSH Key acts like a padlock and key that must be the same and appropriate. Because both key and padlock components are placed on the SSH client and server. The lock will not open if you use a different key.
How SSH key differs to password? A password is a one-way key that consists of several unencrypted characters and can be solved by a particular method. So, a password doesn’t have public_key component and private_key.
Step 1 – Create an SSH Key
The first thing to do is create a paired key by typing the command:
$ ssh-keygen -t rsa
This command will generate private_key and public_key which can later be used on the SSH client computer and server.
You will be given a few questions,
Enter file in which to save the key (/home/cincun/.ssh/id_rsa):
This is used to set a folder to place public_key and private_key. By default the storage folder is in /home/cincun/.ssh/id_rsa.
Enter passphrase (empty for no passphrase):
This is used to set the password again when trying to access SSH. If it’s emptied then when logging into the server doesn’t need to re-login. Simply use $ ssh @ and it can go directly to the server.
When finished, it will display “the key fingerprint”.
There would be two files: id_rsa and id_rsa.pub.
The id_rsa.pub file must be uploaded to the server as a padlock for that server. While the id_rsa file remains on the SSH client computer. The goal is if the id_rsa.pub file already exists on the server, then, another computer can login with the same key.
So, for security, don’t give the id_rsa file to anyone because later they can easily login to your server.
Step 2 – Copying the SSH Key to the Server
Once the key is created, the padlock needs to be placed on the server.
You can use the following simple commands:
$ ssh-copy-id user@serverip
[cincun@cincun ~]$ ssh-copy-id email@example.com
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys
Then, the display will appear to ask for a password, enter your user password. The following information will appear;
Number of key(s) added: 1
Now try logging into the machine, with: “ssh ‘firstname.lastname@example.org′”
and check to make sure that only the key(s) you wanted were added.
It indicates that the key has been successfully copied to the server. So, in the future, you are no longer need to enter the password again when you want to log into the server. Simply type $ ssh <user>@<hostname> because there wasn’t passphrase entered on the key generator.
Basic SSH Commands
Linux’s basic commands are the same as SSH’s basic commands, but the server you’re using uses Linux.
There are two ways of using SSH to connect to a remote server, which is by using SSH Key and without a key. But to use SSH to connect to a remote server using an SSH Key is quite safe than without a key.
Take into account that after creating the SSH key, make sure on other people recognize the key except you. Because when anyone knows that key, he or she can easily get into the server which has the key pair.