在 PowerShell 中使用 New-SshSession(使用私钥)远程登录 Linux 失败并显示 "Invalid private key file"
Remotely login to Linux using New-SshSession in PowerShell (with a private key) fails with "Invalid private key file"
我正在尝试使用带有下面列出的 3 个输入的密钥从 Windows PowerShell 登录到 Linux 服务器。
New-SshSession -ComputerName [name] Username- [user] -KeyFile [path]
我从一位同事那里收到了私钥文本,我需要知道如何实现它。将其保存在 .ppk
文件中没有产生任何结果。 PowerShell 吐出以下内容以响应 运行 上面的行。
New-Object : Exception calling ".ctor" with "1" argument(s): "Invalid private key file."
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SSH-Sessions\SSH-Sessions.psm1:90 char:20
+ $Key = New-Object Renci.SshNet.PrivateKeyFile( $Keyfile ) -ErrorActi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
所以我想我需要知道如何将发送给我的字符串保存为密钥?
谢谢!
The manual states that New-SshSession
accepts an OpenSSH key file for initiating and authenticating SSH connections. If you have been given a text file, you can make it into a compatible key file via PuttyGen.exe (link grabbed from page), then you load the .ppk into PuttyGen, then copy&paste generated data. If you've received a HEX2BIN string (the one that has only 0213456789ABCDEF
in it), you have to convert that into a Base64 string. (use https://www.base64decode.com/ 或类似的服务。)
如果您无法创建兼容文件,请向发行人索取以 ssh-rsa
开头的文本文件,可能会将本手册链接到他。
我正在尝试使用带有下面列出的 3 个输入的密钥从 Windows PowerShell 登录到 Linux 服务器。
New-SshSession -ComputerName [name] Username- [user] -KeyFile [path]
我从一位同事那里收到了私钥文本,我需要知道如何实现它。将其保存在 .ppk
文件中没有产生任何结果。 PowerShell 吐出以下内容以响应 运行 上面的行。
New-Object : Exception calling ".ctor" with "1" argument(s): "Invalid private key file."
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SSH-Sessions\SSH-Sessions.psm1:90 char:20
+ $Key = New-Object Renci.SshNet.PrivateKeyFile( $Keyfile ) -ErrorActi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
所以我想我需要知道如何将发送给我的字符串保存为密钥?
谢谢!
The manual states that New-SshSession
accepts an OpenSSH key file for initiating and authenticating SSH connections. If you have been given a text file, you can make it into a compatible key file via PuttyGen.exe (link grabbed from page), then you load the .ppk into PuttyGen, then copy&paste generated data. If you've received a HEX2BIN string (the one that has only 0213456789ABCDEF
in it), you have to convert that into a Base64 string. (use https://www.base64decode.com/ 或类似的服务。)
如果您无法创建兼容文件,请向发行人索取以 ssh-rsa
开头的文本文件,可能会将本手册链接到他。