Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Shell batch key-free login

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Note: ip.txt and send_ssh_key.sh must be in the same root directory

# write server information ip.txt according to the following format for key-free login #-# ipgroup passwordholders 192.168.1.110 VRV 7758521mm 192.168.1.111VOR 7758521VOG 192.168.1.112Rd 7758521pin ssh keyif # generate ssh keyif [!-f "/ root/.ssh/id_rsa"] Then echo "gen ssh key" ssh-keygen-t rsa-b 2048-N'- f / root/.ssh/id_rsafi# checks if expectif is installed! Expect-v & > / ipfor p in $(cat ip.txt | grep-v'#') in the dev/null;then echo "install expect" yum install expect-yfi# loop file Do ip=$ (echo "$p" | cut-F1-d ":") # take out the current IP password=$ (echo "$p" | cut-f2-d ":") # take out the current password # expect interactive process expect-c "spawn ssh-copy-id-I / root/.ssh/id_rsa.pub root@$ip expect {\" * yes/no*\ "{send\" yes\ r\ " Exp_continue}\ "* password*\" {send\ "$password\ r\"; exp_continue}\ "* Password*\" {send\ "$password\ r\";}} "

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report