In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Automatically generate the public key and automatically write it to a specific server script
The sudo permission required for a general account
Zhi.yang ALL= (ALL:ALL) NOPASSWD:/usr/bin/tee-a / root/.ssh/authorized_keys,/bin/mkdir / log/*
# expect/usr/local/bin/sshkey.exp 10.0.0.3 shaa01 zhi.yang xxxxx
#! / usr/bin/expect
Set ip [lindex $argv 0]
Set hostname [lindex $argv 1]
Set user [lindex $argv 2]
Set password [lindex $argv 3]
Spawn ssh-keygen
Expect {
"* id_rsa):" {send "\ r"; exp_continue}
"* passphrase):" {send "\ r"; exp_continue}
"* again:" {send "\ r"}
}
Expect eof
Spawn scp-r / root/.ssh/id_rsa.pub $user@$ip:/tmp/
Expect {
"* (yes/no) *" {send "yes\ r"; exp_continue}
"* Password:" {send "$password\ r"}
}
Expect eof
Spawn ssh $user@$ip
Expect {
"* Password:" {send "$password\ r"}
}
Expect eof
Expect "$*"
Send "sudo mkdir / log/$hostname\ r"
Send "cat / tmp/id_rsa.pub | sudo tee-a / root/.ssh/authorized_keys\ r"
Send "rm-rf / tmp/id_rsa.pub\ r"
Send "exit\ r"
Expect eof
Exec sh-c {/ bin/sh / usr/local/bin/diskG9.sh}
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.