[root@node110 pexpect]# cat simple8_ssh_auto_login.py
#!/usr/bin/env python
import pexpect
import sys
child = pexpect.spawn('ssh root@192.168.198.121')
fout = file('mylog.txt','w')
child.logfile=fout
child.expect("password:")
child.sendline("123456")
child.expect("#")
child.sendline("ls /home")
child.expect("#")
child.sendline("pwd")
child.expect(pexpect.EOF)
2017-04-10
ssh自动登录
评论
发表评论
姓 名: