xbetcNBul4WQTiAXe5Wj0youglaF4UAQjBlvC4sS
Bookmark

How to Use SSH to Remote Server

How to Use SSH to Remote Server

If you have a VPS service, you must be familiar with SSH access. SSH access is essential for managing your VPS, especially for those not using a control panel.

Using SSH is straightforward; simply enter the IP, username, and password to gain full access to your VPS.

In this article, we will discuss the definition of SSH and how to use SSH.

What is SSH?

Secure Socket Shell, or SSH, is a protocol that provides administrator access.

When using SSH, you can connect to a computer or server located in a different location from yours, as long as it is still connected to the same internet network. SSH is used to encrypt the connection between your device and the server in another location.

So, an SSH tutorial will be very useful for those who want to perform remote access.

Usually, Network Administrators and System Administrators use SSH to manage servers remotely. SSH allows users to execute programs, copy, move, and even delete files on the server without physically being present at the server location.

There are two methods of using SSH, with a key and without a key. The method using a key is considered more secure as it requires two-way authentication, both from the client and the server.

By the way, SSH also has its own port. You can read more about it in the article on how to change the SSH port on a VPS.

Also, don't forget to check out the article on how to back up your VPS.

How to Use SSH?

There are several steps to use SSH, including:

  • Installation Process;
  • Establishing SSH Connection Without Key;
  • Establishing SSH Connection Using Key.
For detailed steps, here are the explanations for each point above.

Read also: Iptables Tutorial

1. Installation

Basically, using SSH on all operating systems is the same. However, on the Windows operating system, you usually need additional applications as SSH clients.

Linux

Linux operating systems usually come with SSH applications as clients, so you don't need to install them separately. If your operating system doesn't have an SSH client application, you can install the openssh-client package.

$ sudo apt install openssh-client 

Once installed, the SSH configuration file on Linux (Ubuntu) can be found in the /etc/ssh/sshd_config folder.

Windows

If you are using the Windows operating system, you need to install an SSH client application. There are several options available, such as PuTTY, Bitvise, KiTTY, and others. PuTTY is the most popularly used application; you can download PuTTY from this page.

Read also: VPS Without Panel

2. SSH Connection Without Key

Linux

Step 1 - Open the Terminal application, and once it's open, you can directly enter the username and hostname/ip address of your server.

$ ssh username@host 

The username is filled with the user of the server, while the host is filled with the address or domain of the server.

[technoqyu@technoqyu ~]$ ssh technoqyu@xx.xxx.58.75

technoqyu@xx.xxx.58.75’s password:

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 117.102.64.98

technoqyu@technoqyu:~#

Step 2 - You will be prompted to enter the password; input the password of the respective username. If successful, you will be connected to your server.

Read also: How to Change VPS Password

Windows

Step 1 - Once PuTTY is installed, you can open the application and enter the server address in the "Host Name" field.

How to Use SSH to Remote Server

Step 2 - When the "login as:" window appears, enter the username registered on your server and the password for that username.

Step 3 - If correct, the server terminal will appear, and you have successfully connected to the server system.

Also Read: How to Upload Files to VPS

3. SSH Connection Using SSH Key

SSH Key is one of the components of SSH used to secure the connection between two devices using specific cryptographic techniques.

SSH Key acts like a lock and key that must be the same and match. This is because both the key and lock components are placed on the SSH client and SSH server. The lock cannot be opened with a different key.

Also Read: How to Install WordPress on VPS

What is the difference with a password?

A password is a one-way key consisting of several characters that are not encrypted and can be cracked using specific methods. So, passwords do not have public_key and private_key components.

Step 1 - Generating SSH Keys

The first thing to do is to create a paired key by typing the command:

$ ssh-keygen -t rsa

This command will produce a private_key and public_key that can later be used on the SSH client computer and server.

You will be asked some questions,

Enter file in which to save the key (/home/technoqyu/.ssh/id_rsa):

This is used to set the folder to place the public_key and private_key. By default, the storage folder is located at /home/technoqyu/.ssh/id_rsa.

Enter passphrase (empty for no passphrase):

This is used to set a password when attempting to access SSH. If left empty, there is no need to provide a password during login to the server. Just use $ ssh <user>@<hostname>, and you can directly access the server.

After completion, the "the key fingerprint" display will appear.

How to Use SSH to Remote Server

The id_rsa.pub file must be uploaded to the server as a lock for the server, while the id_rsa file should remain on the SSH client's computer. The purpose is that once the id_rsa.pub file is present on the server, other computers can log in using the same key.

Therefore, for security reasons, do not give the id_rsa file to just anyone, as they could easily gain access to your server.

Step 2 - Copying SSH Keys to the Server

Once the keys have been generated, the lock needs to be placed on the server.

You can use the following simple command:

$ ssh-copy-id user@serverip
[technoqyu@technoqyu ~]$ ssh-copy-id root@xx.xxx.58.75

/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

root@31.220.58.75’s password:

Then, a prompt will appear to ask for the password, enter your user's password.

Next, you will see the information:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'root@31.220.58.75'"

and check to make sure that only the key(s) you wanted were added.

That indicates the key has been successfully copied to the server.

From now on, you don't need to enter the password again when you want to access the server. Simply type $ ssh <user>@<hostname>, because no passphrase was added during key generation.

Read also: How to Check VPS RAM

Basic SSH Commands

The basic SSH commands are similar to basic Linux commands if the server you're using is Linux. I have already created a guide on these basic commands, and you can visit that guide under the topic "50+ Basic Linux Commands You Must Know."

Also Read: How to Check VPS IP

Conclusion

There are two methods for using SSH: using SSH keys and using regular SSH connections without keys. The method of using SSH keys is considered more secure compared to not using them.

After creating the keys, make sure they are not shared with other users, as those who possess the keys can easily access your server, which already has a paired key.

Post a Comment

Post a Comment