JIYIK CN >

Current Location:Home > Learning > OPERATING SYSTEM >

SSH to the remote server

Author:JIYIK Last Updated:2025/04/05 Views:

This article demonstrates how to use to sshsecurely connect to a remote Linux server.

Securely access remote Linux servers using SSH (Secure Socket Shell)

SSH is the abbreviation of Secure Socket Shell. It is a protocol used to securely access remote Linux machines.

Once the SSH connection is established between your computer and the remote Linux machine, a shell is started on the remote Linux machine and you can access this shell on your computer. You can use this shell to run all the commands on the remote Linux machine like your local computer.

SSH protocol is very secure for accessing remote Linux machines and is commonly used by system and network administrators to maintain and configure remote Linux machines.

SSH uses a client-server architecture. It has a client-side component and a server-side component. People who want to access a remote Linux machine need to install an SSH client on their machine.

SSH client is a program to access a remote Linux machine. The person enters the remote Linux machine's information and credentials into the SSH client and if the details are valid, a secure SSH connection is initiated.

The server-side component runs on a remote Linux machine, which needs to have the SSH service installed, started, and running.

The SSH service continuously listens for incoming connections on a specific port (such as a server). If an SSH client initiates a connection, the SSH service responds with the protocol version it supports, and the two exchange identification data. Once the credentials are valid, the SSH connection is established.

There are many SSH tools available. OpenSSH is one of them, mainly used in Linux distributions. This tutorial will use OpenSSH for demonstration.

Install OpenSSH client in Linux

Many Linux distributions come with an SSH client already installed. In Linux, it is always a good idea to check if a program is already installed before installing it.

We check if it is already installed by typing sshand pressing .Enterssh

ssh img1

sshThe command displays its usage in the standard output. This means that the SSH client has been installed. If the SSH client is not installed, install it before continuing with this tutorial.

Type the following command to install OpenSSH client on your machine. It will ask you to enter the superuser password, provide the password to continue with the installation.

sudo apt-get install openssh-client

Windows users can use the well-known PuTTYprogram as an SSH client.

Install OpenSSH server on the remote Linux machine

Before accessing a remote Linux machine, make sure that the OpenSSH server is installed on that machine. If not, make sure to install it.

To install the OpenSSH server on Linux, run the following command.

sudo apt-get install openssh-server

We try to install OpenSSH server in the image below, but the machine says that we already have OpenSSH server installed on our machine.

ssh img2

Start the OpenSSH server on the remote Linux machine

After successfully installing OpenSSH server on the remote Linux machine, we need to start the OpenSSH service to listen for incoming connections from SSH clients.

First, we sudo service ssh statuscheck the status of the OpenSSH service by typing . The output below indicates that the service is inactive.

ssh img3

We use sudo service ssh startthe command to start the OpenSSH service. This command starts sshthe daemon running.

We use sudo service ssh statusthe command to check the status of the service. The output shows that the service is now in 活动(运行)status.

The remote Linux machine has the OpenSSH server installed and it is up and running. It is now ready to accept incoming connections from SSH clients.

ssh img4

Use sshcommand to access remote Linux machine

We create a new user on the remote Linux machine, which we will use for demonstration purposes in this tutorial. Using useraddthe command, we create a new user jiyik.

We use passwdthe command to set the user's password jiyik.

$ useradd jiyik
$ passwd jiyik
Enter New Unix password
Retype New Unix password

Now, we go into the machine where OpenSSH client is installed and try to jiyikaccess the remote Linux machine using the newly created user.

SSH uses the following notation to log into a remote Linux machine.

ssh username@remotehostname
ssh username@remoteIPaddress

SSH will ask for the user's password delftstack, enter the password and press Enter. After seeing the output below, you have successfully logged into the remote Linux machine.

$ ssh jiyik@localhost

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

How to decompress x.tar.xz format files under Linux

Publish Date:2025/04/08 Views:186 Category:OPERATING SYSTEM

A lot of software found today is in the tar.xz format, which is a lossless data compression file format that uses the LZMA compression algorithm. Like gzip and bzip2, it supports multiple file compression, but the convention is not to compr

Summary of vim common commands

Publish Date:2025/04/08 Views:115 Category:OPERATING SYSTEM

In Linux, the best editor should be vim. However, the complex commands behind vim's powerful functions also make us daunted. Of course, these commands do not need to be memorized by rote. As long as you practice using vim more, you can reme

Detailed explanation of command return value $? in Linux

Publish Date:2025/04/08 Views:58 Category:OPERATING SYSTEM

? is a special variable. This variable represents the return value of the previous command. That is to say, when we run certain commands, these commands will return a code after running. Generally, if the command is successfully run, the re

Common judgment formulas for Linux script shell

Publish Date:2025/04/08 Views:159 Category:OPERATING SYSTEM

In shell script programming, predicates are often used. There are two ways to use predicates, one is to use test, and the other is to use []. Let's take a look at how to use these two methods through two simple examples. Example 1 # test –

How to use the Linux file remote copy command scp

Publish Date:2025/04/08 Views:151 Category:OPERATING SYSTEM

Scp copies files between two hosts over the network, and the data is encrypted during transmission. Its underlying layer uses ssh for data transmission. And it has the same authentication mechanism and the same security level as ssh. When u

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial