Thank you for your friends to support this blog, welcome to discuss the exchange, due to limited capacity and time, mistakes are unavoidable, please correct me!
If reproduced, please keep the source author blog information.
Better Me Blog: Blog.csdn.net/tantexian
If you need to communicate, welcome to blog message.
Automatic script implementation with no key login: Vim auto_ssh.sh
#!/usr/bin/expectSetTimeoutTen Setusername [lindex $argv0] SetPassword [lindex $argv1] Sethostname [Lindex $argv2] Spawn ssh-copy-id-i/root/.ssh/id_rsa.pub [email protected] $hostnameexpect {#first Connect, no PublicKeyinch~/.ssh/known_hosts"Is you sure want to continue connecting (yes/no)?"{Send"yes\r"expect"Password:"Send"$password \ r"} #already has PublicKeyinch~/.ssh/known_hosts"Password:"{Send"$password \ r" } "Now try logging to the machine"{#it has authorized, Donothing!}}expect EOF
chmod 777 Auto_ssh.sh then execute the following command:/auto_ssh.sh root 123456 192.168.10.162 test result 162 machine upload look: Success!
Automatic script implementation without key login (Ssh-copy-id, expect free interactive input script)