基本上是标题。我的朋友提供了一个脚本来通过 Powershell 和 PuTTY 批量更改 RHEL 密码,但是当我尝试登录时,我输入的新密码不起作用。我认为问题是它没有转义一个特殊字符在新密码中,但我不知道新密码是什么。
我使用的“新密码”类似于:a1b2c3d"4e5f6g7
我尝试将安全字符串替换为常规字符串,或者使用 telnet 而不是 SSH 与数据包捕获来确定发送的究竟是什么,但到目前为止这些都没有奏效。
System.Management.Automation.PSCredential -argumentlist "root",$newrootPassword
$newrootPassword2 = Read-Host "Retype new root password" -AsSecureString
$newrootCredential2 = new-object -typename System.Management.Automation.PSCredential -argumentlist "root",$newrootPassword2
putty.exe -ssh -pw $oldrootCredential.GetNetworkCredential().Password root@$_
echo y | plink.exe -ssh -v -pw $oldrootCredential.GetNetworkCredential().Password root@$_ "echo root:'$newrootPassword' | chpasswd" 2>&1
Run Code Online (Sandbox Code Playgroud)
我希望新密码是 a1b2c3d"4e5f6g7;但是,这在登录时不起作用。