Fingerprint SFTP connection variable assigned PowerShell

Advertisement

Madeproel
Guest

Fingerprint SFTP connection variable assigned PowerShell

Hello,

I have a PowerShell script in which the credentials are set dynamically via variables. For hostname, username, password this works. But not for the fingerprint. I always get the following message:
New-Object : The specified value is invalid, or the property is read-only. Change the value and repeat the operation.
Here is an excerpt of my script. The values was replaced by "xxxx".
function getCreds(){
    $creds=[PSCustomObject]@{
        hostname = ''
        username = ''
        pwd = ''
        fingerprint = ''   
    }
    $creds.hostname = 'xxxx'
    $creds.username = 'xxxx'
    $creds.pwd = 'xxxx'
    $creds.fingerprint = 'ssh-rsa 1024 xxxx'
    return $creds
}
 
function transferFile($creds){
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = $creds.hostname
        UserName = $creds.username
        Password = $creds.pwd
        SshHostKeyFingerprint = $creds.fingerprint
    }
}
$creds=getCreds()
transferFile($creds)

Reply with quote

Advertisement

Paul Martell-Mead
Guest

Same here

I am seeing the exact same behaviour here.

I have an INI file containing the settings for the script which reads key/value pairs into PowerShell variables. All parameters work fine this way except SshHostKeyFingerprint. I can use my SshHostKeyFingerprint value hard-coded in the script and it works fine, so this proves it isn't an issue with the actual value (which is what the above answer implies).

Reply with quote

Paul Martell-Mead
Guest

Figured it out

Right – so the issue for me is I had the value enclosed in quotes and this won't pass validation for the fingerprint.

Reply with quote

Advertisement

You can post new topics in this forum