Table of contents
3. Reuse the xshell remote connection successfully
When using centos7 to build a server, I don’t know why xshell suddenly can’t log in for no reason. You can try to reinstall ssh.
1. Login
I am using Tencent Cloud, so I log in on the Tencent Cloud server web page.
You can first find the problem of the server in the work order system
2. Process
1.service sshd start
2.journalctl -xe
journalctl -xe
An error as shown in the figure appears:
sshd.service: main process exited, code=exited, status=203/EXEC.
init: ssh main process (1843) terminated with status 255.
3. Execute the following command to check the environment variable configuration.
echo $PATH
4. Compare the actual returned PATH environment variable with the default value. PATH environment variable default value:
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
5. If the actual returned PATH environment variable is different from the default value, you need to execute the following command to reset the PATH environment variable.
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
6. Execute the following command to find and confirm the sshd program path.
find / -name sshd
7. If the returned result is as follows, it means that the sshd program file already exists.
/usr/sbin/sshd
8. If the corresponding file does not exist, reinstall the SSH software package.
8.1 View command:
rpm -qa openssh*
8.2 Uninstall command
yum remove openssh*8.3 Reinstall the ssh service
yum -y install openssh-clients
yum install openssh-server
8.4 After the installation is complete, check whether it is installed:
rpm -qa|grep ssh
8.5 Modify the configuration file
vim /etc/ssh/ssh_config
去掉#:Port 22、ListenAddress、PermitRootLogin yes、PubkeyAuthentication yes
9. Start the ssh service:
systemctl start sshd.service
10. Check the running status of the ssh service:
systemctl status sshd.service
11. Open the 22 port command of the firewall:
sudo firewall-cmd –zone=public –add-port=22/tcp –permanent
sudo service firewalld restart
12. Query the current program running port number:
netstat -anpl |grep sshd
Port 22 must be monitored
3. Reuse the xshell remote connection successfully