首页 > 代码库 > python ssh登录
python ssh登录
3. 编写linkssh.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# filename: pexpect_test.py
‘‘‘
Created on 2012-03-31
@author: qvb3d
‘‘‘
import pexpect
if __name__ == ‘__main__‘:
user = ‘root‘
ip = ‘192.168.1.8‘
mypassword = ‘不能写了‘
child = pexpect.spawn(‘ssh %s@%s‘ % (user,ip))
child.expect (‘password:‘)
child.sendline (mypassword)
child.interact() # Give control of the child to the user.
pass
保存
4.执行 python linkssh.py
5.这时你就可自动进入ssh
注意喽,这个文件可不要谁都给喽
你的密码在里面呢
python ssh登录
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。