Closed viju3010 closed 11 months ago
My Code :
# Remove trusted host keys to make host key validation succeeds
try{
Write-host "Removing trusted host keys from the local host"
$removeTrustedHosts = Get-SSHTrustedHost -Hostname $VC_ip | Remove-SSHTrustedHost -ErrorAction SilentlyContinue
# Invoke-Expression "ssh-keygen -R $VC_ip"
Write-host "Removed trusted host keys from the local host"
}
catch{
Write-host "Could not remove trusted host keys"
Write-Host $_.Exception|format-list -force
}
Error :
Removing trusted host keys from the local host
PS>TerminatingError(Get-SSHTrustedHost): "Exception calling "GetAllKeys" with "0" argument(s): "Additional text encountered after finished reading JSON content: }. Path '', line 33, position 0.""
Could not remove trusted host keys
System.Management.Automation.MethodInvocationException: Exception calling "GetAllKeys" with "0" argument(s): "Additional text encountered after finished reading JSON content: }. Path '', line 33, position 0."
---> Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: }. Path '', line 33, position 0.
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at SSH.Stores.JsonStore.LoadFromDisk()
at SSH.Stores.JsonStore.OnGetKeys()
at SSH.Stores.MemoryStore.get_HostKeys()
at SSH.Stores.MemoryStore.GetAllKeys()
at CallSite.Target(Closure, CallSite, Object)
--- End of inner exception stack trace ---
and what
Additional text encountered after finished reading JSON content
you see in $env:USERPROFILE\.poshssh\hosts.json
?
line 33, position 0.""
{
"Keys": {
"xx.xx.0.14": {
"HostKeyName": "xxxx",
"Fingerprint": "xxxxxx"
}
}
}
}
Looks like an additional bracket at the end
After removing the } in the end, the commands are working. Thank you !
Hi Team, I am noticing the below issue when trying to list "Get-SSHTrustedHost". This happens one some of my jenkins slaves and I have multiple things including to reinstall the module.