Recently, when combining the lniautoconf and autossh scripts, I encountered a problem: at the end of the Kickstart file, I copied the Public Key generated by the root user directly to the target machine/root /. in the SSH directory, so that the SSH password-less login is OK in key preparation.
But then I encountered a tricky problem: When I log on to the other node by Using SSH for the first time, there will be an interactive prompt on whether to add the hostkey. I have to answer Yes/No, although we only need to answer this question once, it causes a big problem for our automation script. If this problem is not solved, it means that after the user finishes using this script, execute a secondary CT script to solve the yes/no condition of each node, this violates the original intention of merging these two scripts. If you need to execute other scripts after executing this script, you can completely complete the automatic deployment of Linux OS + SSH Login password, this is equivalent to letting the user execute two scripts, so it makes no sense to merge lniautoconf and autossh at first. Therefore, this problem must be solved.
Fortunately, after checking man ssh_config, this problem can be solved. Create the file config in the/root/. Ssh directory. If it is a common user, it is ~ /. Add a line in the SSH directory:
Stricthostkeychecking No
In this way, if no key is added to the host during SSH Login, the key will be automatically added ~ /. Ssh/known_hosts file. The default value is ask, so a prompt is displayed. This project can also be configured to yes, which is the most rigorous check. In this case, you need to manually add the key ~ /. Ssh/known_hosts file.
To speed up SSH Login, a scientific approach is to add the Client IP address and hostname ing to the server's hosts file, or configure a DNS server to resolve all machines. Of course, there are also ways to be lazy: edit/etc/ssh/sshd_config and add a line: usedns No, which can greatly speed up SSH Login Time.