【发布时间】:2018-04-14 15:38:31
【问题描述】:
我想在 PowerShell 中加密密码并将其与 plink 和 putty 一起使用。
是的,我知道它只需要明文密码 (Password encryption using SecureString for plink.exe command)。
不,我不会使用生成的密钥,因为我们不支持它。
我的问题:
- 任何建议如何在
putty或plink中为-pw标志使用加密密码 - 我可以生成特定的字符串作为键吗?我的意思是获取当前的明文密码并将其转换为密钥,然后将其用作
-i而不是-pw
我的securePass.ps1 代码:
$password = read-host -prompt "Enter your Password"
write-host "$password is password"
$secure = ConvertTo-SecureString $password -force -asPlainText
$bytes = ConvertFrom-SecureString $secure
$bytes | out-file C:\encrypted_password1.txt
主要:
$securePass = Get-Content C:\encrypted_password1.txt
$pass = $securePass | ConvertTo-SecureString
plink -batch -ssh $defUser@$srv -pw $pass
putty -ssh $defUser@$srv -pw $pass
【问题讨论】:
标签: powershell encryption putty ssh-keys plink