windows界面下实现ssh自动登录,并执行命令:


准备工作:

1、确保windows系统已经安装openssh程序。

image.png

2、用vbs模拟键盘输入密码,实现ssh自动登录执行命令。



set wshshell=Wscript.CreateObject("WScript.Shell")
wshshell.Run "ssh root@192.168.7.11"  //用户名和IP地址
Wscript.Sleep 1000
wshshell.SendKeys "root"  //密码
wshShell.SendKeys "{ENTER}"
Wscript.Sleep 1000
wshshell.SendKeys "ls"
wshShell.SendKeys "{ENTER}"

第一次登录需要验证需手动输入:yes

image.png

image.png

加载中~