0

I have written a script as below

$ipAddress = "10.10.10.10" 
$username = Get-Content -Path "path to user name"
$password = Get-Content -Path " path to password"
$hostkeyF="aa:bb:cc:dd:ee:ff:gg:hh:JJ:kk:"
# Define the path to the Plink executable
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
$sshCommand = "& '$plinkPath' -batch -ssh -hostkey $hostkeyF $username@$ipAddress -pw $password"
Invoke-Expression -Command $sshCommand

When I run it in PowerShell ISE I get error

Host key did not appear in manually configured list

What I am trying to do is create a PowerShell script which connects to a remote device later I will improve it.

But issue is I want all the user to use this code present in my network hence I want to bypass first time hostkey verification.

Sorry if I sound confusing
Let me know if you need any other details

Please note that I cannot install any new module to solve this as it is restricted.

I have OpenSSH and Plink with me to work on this.

Thank you in advance

Martin Prikryl
205k64 gold badges561 silver badges1.1k bronze badges
asked Aug 12, 2023 at 3:34
0

1 Answer 1

0

With OpenSSH, you can use accept-new mode.

ssh -o StrictHostKeyChecking=accept-new example.com

Plink does not have an equivalent functionality. All it supports is explicit specification of hostkey fingerprint using the -hostkey switch.

answered Aug 14, 2023 at 4:38
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.