First create a expect script ssh_expect with the following file contents:
#!/usr/bin/expect-fSethostname [lindex$argv 0]SetUser [lindex$argv 1]Setpasswd [lindex$argv 2]SetTimeout -SetForce_conservative1if{$force _conservative} {SetSend_slow { -.1}}spawn SSH$user@$hostname; expect {"*continue connecting (yes/no)?"{Send- S "Yes\r"; Exp_Continue}"*assword:"{Send- S "$passwd\ r"; }}interact
Then define some command aliases, such as:
alias h101=‘ssh_expect 192.168.0.101 <user> <password>‘alias h102=‘ssh_expect 192.168.0.102 <user> <password>‘
These aliases can be written to the ~/.BASHRC file.
Then execute h101 to automatically log on to the 192.168.0.101 machine.
Please indicate this address in the form of a link.
This address: http://blog.csdn.net/kongxx/article/details/48675885
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux uses expect scripts to automate remote machine logon