Batch file 执行;苏";使用批处理文件中的PuTTY Plink
在PuTTY/Plink中,我很难让批处理文件同时为我提供超级用户访问权限。我可以自动输入ip和密码,但我还想将其自动化,以便在运行此批处理文件时,它也能为我提供Batch file 执行;苏";使用批处理文件中的PuTTY Plink,batch-file,ssh,putty,plink,Batch File,Ssh,Putty,Plink,在PuTTY/Plink中,我很难让批处理文件同时为我提供超级用户访问权限。我可以自动输入ip和密码,但我还想将其自动化,以便在运行此批处理文件时,它也能为我提供su访问权限。到目前为止,它一直运行到我需要手动输入su的地步,但我正在尝试自动输入,所以我尝试了-m commands.txt,现在它崩溃了。。这里需要帮助,谢谢 这就是我目前所拥有的 @echo off color b cls echo What is the IP for the unit?: set /p IP= : echo
su
访问权限。到目前为止,它一直运行到我需要手动输入su
的地步,但我正在尝试自动输入,所以我尝试了-m commands.txt
,现在它崩溃了。。这里需要帮助,谢谢
这就是我目前所拥有的
@echo off
color b
cls
echo What is the IP for the unit?:
set /p IP= :
echo What is the SSH Password for this unit?:
set /p Passw0rd= :
echo What is the Root Password for this unit?:
set /p ro0t= :
start plink.exe -ssh user@%IP% -pw %Passw0rd% -m commands.txt
exit/b
commands.txt
中的内容:
su
当然,
su
会提示您出了什么问题。但您无法看到它,因为您在一个新的控制台窗口中使用start
启动plink
,该窗口立即消失。至少在调试问题时,删除启动
无论如何,您很可能会收到“标准输入必须是tty”或类似的消息。默认情况下,su
需要终端提示密码。Plink是一种自动化的设备,而不是交互式的设备。因此,默认情况下,它不会为会话分配伪终端。要强制使用终端,请添加:
类似的问题:
下一步,您可能需要在
su
中执行更多命令。那就看吧
不过请注意,一般来说,使用密码自动化
su
,尤其是su
,通常是个坏主意:。请参阅
plink.exe -t -ssh user@%IP% -pw %Passw0rd% -m commands.txt