Powershell - set SSH Privatekey Repository Value

Powershell - set SSH Privatekey Repository Value

avatar
d01
Disabled

Hi,

I cannot set the privatekey repository value:

If ($SSHKeyFile) {

$SSHSession = Get-RDMSession | Where-Object {$_.Name -eq $SSHKeyFile}

$SSHKeyGUID = $SSHSession.ID

write-Host "Key File Record Found" -ForegroundColor Magenta

Set-RDMSessionProperty $Session.ID -Path "Terminal" -Property "PrivateKeyPromptForPassPhrase" -Value "false"

Set-RDMSessionProperty $Session.ID -Path "Terminal" -Property "PrivateKeyType" -Value 3

Set-RDMSessionProperty $Session.ID -Path "Terminal" -Property "Username" -Value $CredentialUserName

write-host $SSHkeyGUID

Set-RDMSessionProperty $Session.ID -Property "PrivateKeyConnectionID" -Value "$SSHKeyGUID"

}

Any ideas?

Thanks in advance.

All Comments (5)

avatar

Hello,

have you called

Set-RDMSession $Session

After those assignements?

if so, is there an error message?

Thanks

Regards,

Alex Belisle

avatar
d01
Disabled

Hi,

Sorry for not coming back sooner.

I still cant get this to work

Set-RDMSessionProperty $Session.ID -Property "PrivateKeyConnectionID" -Value "$SSHKeyGUID"

avatar

Hello,

Under which version of RDM are you trying this?

Have you tried to call

Set-RDMSession $Session

after setting the properties?

Best regards,

Alex Belisle

avatar
d01
Disabled

Hi Alex,

Thanks for the reply.

I already have this line. Here is the complete script.

$Template = "861e32d7-c639-4377-b238-34535b99193e"

#$VerbosePreference = "Continue"

write-Host "in SSH" -ForegroundColor green

write-Host "$ConnectionType $Name $Group $HostIP $Port $CredentialUserName $CredentialPassword" -ForegroundColor Green

##################################################

# Test Existing RDM Entry #

##################################################

$Session = Get-RDMSession | Where-Object {$_.Name -eq $Name -and $_.Group -eq $Group}

If ($Session) {

write-Host "Existing Record" -ForegroundColor Magenta

}

##################################################

# Create RDM Entry #

##################################################

else

{

write-host "New Record" -ForegroundColor Yellow

$Session = new-rdmsession -group $Group -host $HostIP -name $Name -setsession -TemplateID $Template -type "SSHShell"

write-output $Session.ID

}

##################################################

# Update RDM Entry #

##################################################

Update-RDMUI

write-host "Updating Record" -ForegroundColor white

If ($SSHKeyFile) {

$SSHSession = Get-RDMSession | Where-Object {$_.Name -eq $SSHKeyFile}

$SSHKeyGUID = $SSHSession.ID

Update-RDMUI

write-Host "Key File Record Found" -ForegroundColor Magenta

write-host $SSHkeyGUID

Set-RDMSessionProperty $Session.ID -Path "Terminal" -Property "PrivateKeyPromptForPassPhrase" -Value "false"

Set-RDMSessionProperty $Session.ID -Path "Terminal" -Property "Username" -Value $CredentialUserName

Set-RDMSessionProperty $Session.ID -Path "Terminal" -Property "PrivateKeyType" -Value 3

Set-RDMSessionProperty $Session.ID -Property "PrivateKeyConnectionID" -Value "$SSHKeyGUID"

Set-RDMSessionProperty $Session.ID -Path "Terminal" -Property "Host" -Value "$HostIP"

Set-RDMSessionusername $Session.ID -Username $CredentialUserName

}

Set-RDMSession $Session

Update-RDMUI

avatar

Hello,

I'm not sure of this one, but I think that what actually kills it is this last "Set-RDMSession $Session"...

According to my tests,

Set-RDMSessionProperty $Session.ID -Property "PrivateKeyConnectionID" -Value "$SSHKeyGUID"

will set the correct value, and, sorry for misleading you, but the Set-RDMSession is not required, even worst, it kills the change you actually made successfully before.

Reason: $Session still contains the former value of the PrivateKey Connection ID, therefore Set-RDMSession just reverts it to its former value.

I hope this helps, thanks for keeping us in touch.

Best regards,

Alex Belisle