Windows: A Complete Guide to SSH Remotely Connecting to Linux Servers

The following are detailed steps for using SSH on Windows systems to remotely connect to a Linux server (we take Ubuntu and CentOS as examples)

Ubuntu:

1. Make sure the Linux server has SSH enabled

First, make sure the SSH service is installed and running on your Linux server. For most Linux distributions, OpenSSH is the default SSH server. You can install it using the following command:

sudo apt-get update
sudo apt-get install openssh-server

 Then, make sure the SSH service is running:

sudo service ssh status

2. Obtain the IP address of the Linux server

On a Linux server, use the following command to obtain the IP address:

 ip addr

 Note the IPv4 address, for example 192.168.1.100.

 CentOS 7:

The steps to set up an SSH service in CentOS 7.9 and connect remotely from Windows are as follows:

1. Enable SSH on CentOS 7.9

Install OpenSSH server

In most CentOS installations, the OpenSSH server comes pre-installed. If not, you can install it using the following command:

(If you are an administrator user, you do not need to enter sudo)

sudo yum install openssh-server

Start SSH service 

sudo systemctl start sshd

Set the SSH service to start automatically at boot

sudo systemctl enable sshd

Check SSH service status

sudo systemctl status sshd

 As shown in the figure below, it means that the SSH service is enabled and the SSH service status is active.

2. Obtain the IP address of the CentOS server

On the CentOS server, use the following command to obtain the IP address:

 ip addr

Find the ens33 or inet address under your primary network interface. This is your server IP address.

 Connecting to a CentOS server from Windows using an SSH client

Use the SSH client that comes with Windows

Starting with a version of Windows 10, Microsoft began including an OpenSSH client as part of its operating system, so you may already have it installed on your system. If not, you can add it from the Features app, see How to Connect to a Windows System Remotely via SSH Guide for details. Steps to install OpenSSH Server

  1. Open a command prompt or PowerShell.
  2. Enter the following command to connect to the CentOS server:
ssh 用户名@服务器IP地址

For example:

ssh [email protected]

 When connecting to the server for the first time, the system will ask whether to accept the server's public key. Type yes and press Enter.

Enter the CentOS user's password and press Enter.

As shown below, the login is successful.

 

problem solved

FAQ 1

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! appears

reason :

This is a security warning for SSH. This warning usually occurs in the following situations:

The target server's public key has changed. This could be because you reinstalled the server, replaced the server hardware, or manually changed the server's SSH keys.
Someone attempted a Man-in-the-Middle attack on your connection. This situation is relatively rare, but cannot be completely ruled out.
Solution:

In order to solve this problem, you should first determine the cause. If you are confident that the server's public key has been legitimately changed, you can follow these steps to resolve it:

Open a terminal or command prompt.

Use the following command to delete the old key entry for the specified IP address:

ssh-keygen -R 192.168.136.128       //你的ssh服务器IP

Afterwards, you can try connecting to the server again. When connecting for the first time, you will be prompted to accept the new public key. After confirmation, you can connect normally. However, if you have not made any changes to your server and are disturbed by this warning, you should investigate further to ensure that your network environment is not under attack.

Precautions

1. Please ensure that the network communication between your client and server is in good condition

Guess you like

Origin blog.csdn.net/weixin_72910567/article/details/132418542