Xshell connects (in vm) Ubuntu-server via ssh

Software environment configuration:

  • OS Windows 10 Professional Workstation Edition (v1909 x64);
  • VMware Workstation Pro 15.6;
  • ubuntu-20.04-live-server-amd64.iso;
  • Client connection tool Xshell 6;

Based on the above environment, the ubuntu-server system has been installed and deployed in the vm, the network mode is bridged, and the external network can be accessed, and the communication between the hosts is normal, as shown below:

 

 Next, we use the Xshell client to connect to ubuntu, and the connection fails=》

Could not connect to 'ip' (port 22):Connection failed.

 Xshell command connection="[$ ssh remote machine name@ip or telnet ip]

A window prompting to enter a password will pop up when the access is successful, which is the same as the above interface connection operation, but still cannot be accessed;

Next, we check whether port 22 used by the ssh connection is open on ubuntu in the vm:

Command = "[$ lsof -i:22] displays the following information:

At this time, you need to install [openssh-server and openssh-client]:

Command = "[sudo apt install openssh-server openssh-client], the prompt message enters Y and waits for the installation to complete;

service ssh start
ssh localhost
lsof -i:22

#注意:以上步骤安装完成后执行上面命令重启;

Now enter Ubuntu to check the status of port 22, whether port 22 is open;

Command = "[netstat -ntlp|grep 22]

Open the port, use Xshell to connect again, normal access, as shown below:

Select [Accept and Save], continue to enter the account password, and click OK to connect normally;

If there is a problem with the installation of [openssh-server], it is recommended to uninstall and reinstall:

#彻底删除openssh-server
sudo apt remove --purge openssh-server 
#安装openssh-server
sudo apt install openssh-server
#启动openssh-server
sudo service ssh restart 
#查看ssh是否启用
ps -e|grep ssh 
#查看监听端口22
netstat -tnl
#查看openssh版本命令
ssh -V
openssl version

The above process records the whole process encountered when Xshell connects to the ubuntu system in vm. I hope to help more friends; 

 

 

Guess you like

Origin blog.csdn.net/ChaITSimpleLove/article/details/108542730