admin管理员组

文章数量:1537269

Winpexpect安装
https://pexpect.readthedocs.io/en/stable/overview.html#pexpect-on-windows
这里使用的是pip安装
pip install winpexpect

Winpexpect 实现ssh连接
核心代码如
child = winpexpect.winspawn(‘ssh -tt root@192.168.100.99’)
注:
【1】winpexpect 与pexpect还是有区别的,run(), pxssh()均不可使用,所以这里用的是winpawn
【2】我在Windows上安装了openssh,未安装前调用该行报错“command cannot found:ssh”
【3】ssh连接时前加-tt,未加时报错Pseudo-terminal will not be allocated because stdin is not a terminal

密钥连接
child = winpexpect.winspawn( ‘ssh -tt -p 22 -i C:\id_rsa(id_rsa存放路径) root@192.168.100.99’)

仅供参考

本文标签: 版本winpexpectWindowspexpect