Hi there,
is there any best practice to start a remote connection via ssh. I ve tried Posh-SSH… But still i cant create a connection. i would like to save the connection information into a secret variable.
Hi there,
is there any best practice to start a remote connection via ssh. I ve tried Posh-SSH… But still i cant create a connection. i would like to save the connection information into a secret variable.
Hi,
can you share some code to see if the problem lays in it?
We are using Posh-SSH to make SNMP get and walks on a dedicated linux vm and this works without a problem.
begin {
if($PSCmdlet.ParameterSetName -eq "Single") {
$SshSession = New-SSHSession -ComputerName $ComputerName -Credential $secret:SshCredential -AcceptKey -Verbose
}
}
process {
$Continue = $true
$OidQueries = @()
$QuerySplitted = $OidQuery.split(" ")
....
$SshOutput = @()
$SshErrors = ""
foreach($Query in $OidQueries) {
$SshResult = Posh-SSH\Invoke-SSHCommand -SSHSession $SshSession -Command $Query
$SshOutput += $SshResult.Output
$SshErrors += $SshResult.Error
}
....
And yes you can save your credentials in variables within PSU.
Hi @MS-Marox,
thx for your reply. After i renewed the secret and used your $sshsession snipplet, it worked like a charm.