How to enable SSH without prompting for adding host key | how to speed up SSH Login

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.