Build the ssh configuration on your own development machine today, and record the problem by the way, so that you can troubleshoot later. Because it is my own development machine, my environment is centos7.
Step 1: View ssh status
First, check the ssh status according to the command. The focus here is whether it is installed and started. If it is not installed, go to the second step. If "Loaded: error (Reason: No such file or directory)" appears, it means that it is not installed. If "Active: inactive (dead)" appears, it means that SSH has been installed and SSH is not enabled.
sudo service sshd status
Step 2: Install ssh
There is a difference here. If it is a centos system, use the command "sudo yum install sshd" to install it, and if it is another system, use "sudo apt-get install sshd".
centos:
sudo yum install sshd
非centos:
sudo apt-get install sshd
Step 3: Open ssh
After the installation is complete, it can be opened and used. Use the command "sudo service sshd start" to start the SSH service. The result of successful activation is "Active: active (running) since Tue 2023-05-30 23:33:01 EDT; 3min 18s ago".
sudo service sshd start
Problem record:
If the following problems occur, it is because the TCP port 22 is first registered with IPV4 in the configuration, and it is definitely not possible to use IPV6 to register port 22 on a machine. The solution is to comment out the IPV6 monitoring. The specific operation is as follows:
error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
error: Bind to port 22 on :: failed: Address already in use.