The first pit: When SSH (Xshell...) connects to the linux host, an error will occur: Could not connect...
the first
Because the firewall cannot connect, you can use the sudo ufw disabled command to disable the firewall. Or when the firewall is open, the command to open port 22 is sudo ufw allow 22
second
Ubuntu does not install the openssh server by default, so if you want to use ssh to remotely log in to the Ubuntu host, you first need to install the ssh server
Determine whether the ssh service is installed in Ubuntu:
Input: #ps -e | grep ssh If the service has been started, you can see "sshd", otherwise it means that the service is not installed, or it has not been started. If it is not the case below, please install ssh
Install the ssh service, enter the command: #sudo apt-get install openssh-server
Start the service: #/etc/init.d/ssh start
This machine tests whether it can successfully log in or log in with other tool links:
#ssh -l username local ip
The second pit: Prompt that the SSH server rejected the password, please try again
When we use root user SSH to connect to the remote host, it shows that the server rejected the password, please try again. This situation is generally caused by the SSH configuration that does not allow the root account to log in.
The solution is: modify the SSH configuration file /etc/ssh/sshd_config
修改 vim /etc/ssh/sshd_config
找到# Authentication:
LoginGraceTime 120
PermitRootLogin without passwd
StrictModes yes
改成
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
Then restart the SSH service
/etc/init.d/ssh restart