Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-SSHSession issues with RSA Key Connection #534

Open
Spydrnyte opened this issue Jun 30, 2023 · 3 comments
Open

New-SSHSession issues with RSA Key Connection #534

Spydrnyte opened this issue Jun 30, 2023 · 3 comments

Comments

@Spydrnyte
Copy link

Script

Import-Module -Name Posh-SSH

$computer = ""
$Credentials = Get-Credential
$privateKeyPath = "C:\Users<PATH>.ssh\id_rsa"
$session = New-SSHSession -Port 22 -ComputerName $computer -KeyFile $privateKeyPath -Credential $Credentials -Verbose
if ($session.Connected -ne "True"){
Write-Output "Trouble connecting to Linux Jump Box. Script cannot be run. Please try again."
$session | Remove-SSHSession
exit
}
return $session

Invoke-SSHCommand $session -Command "ls ~"

Error Received

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
VERBOSE: Fingerprint for : <RSA_KEY Redacted>

Server SSH Fingerprint
Do you want to trust the fingerprint <RSA_KEY Redacted>
[] Y [] N [?] Help (default is "N"): Y
New-SSHSession : Session operation has timed out
At C:\Users<PATH>/test_connect.ps1:6 char:12

  • $session = New-SSHSession -Port 22 -ComputerName $computer -KeyFile $ ...
  •        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationTimeout: (Renci.SshNet.SshClient:SshClient) [New-SSHSession], SshOperationTimeoutException
    • FullyQualifiedErrorId : SSH.NewSshSession

Trouble connecting to Linux Jump Box. Script cannot be run. Please try again.

@MVKozlov
Copy link
Contributor

do you get "Do you want to trust the fingerprint" on every try ?
what timeout values on the server, how much time between question and answer ?
may you add host key manually ?

Get-SSHHostKey  $computer | New-SSHTrustedHost

@Spydrnyte
Copy link
Author

First off I will say I am limited on the version of powershell I can use

Name Value


PSVersion 5.1.19041.3031
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3031
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

@Spydrnyte
Copy link
Author

If I run Get-SSHTrustedHost | Remove-SSHTrustedHost before running the script it does ask "Do you want to trust the fingerprint".

The system I am trying to write for I believe has forwarding
Capture1
Image shows how SSH connection is setup in a client I am trying create Script to run from PC to do some quick resolution tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants