Python Batch establish SSH key (key) authentication

Source: Internet
Author: User
Tags auth ssh

Script in Github:https://github.com/linuxyan/linuxyan/tree/master/python/batch_create_pub_key

After downloading the script, first we have to set up the public key on the management machine, run the following command, all the way to return.

SSH-KEYGEN-T RSA
After creating a good public key, let's look at the script.
The batch_key.py and host.list are the documents we need.
In Host.list, you save the account number and password required to create the key for the first time.
The format is as follows:

ip:port:user:passwd
For example:

192.168.18.46:22:root:123456
192.168.18.13:22:root:123456
Then modify the batch_key.py in the

Home_dir = '/home/yan '
Modify it for your home directory, such as
Home_dir = '/root '
Let's run the script to see the effect:

[Root@localhost batch_create_pub_key]# python batch_key.py
Create host:192.168.18.13. SSH dir ...
Upload id_rsa.pub to host:192.168.18.13 ...
host:root@192.168.18.13 Auth success!

Create host:192.168.18.52. SSH dir ...
Upload id_rsa.pub to host:192.168.18.52 ...
host:root@192.168.18.52 Auth success!

Related Article

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.