I'm trying to automate SSH access to around 100 brand new devices on my local network. I need to connect, accept the host key (security isn't a concern here), issue a command, and then move on to the next device. I've got their IP addresses in a CSV file. The traditional methods I've tried, like using PLINK, haven't worked out—particularly piping 'yes' to it just hangs. I'm looking for a PowerShell script that can do this efficiently without the hassle of logging in manually to each device. Any suggestions?
5 Answers
Have you looked into using Posh-SSH? It might streamline the process for you.
Keep in mind that PLINK has a `-batch` option you can use. It might be the solution you need to avoid those annoying prompts.
Just remember, you don’t actually need to log in to get the key. You can connect and pipe in `echo y` to accept the key. Check your loop structure to make sure it isn’t hanging—try running something like `echo y | plink -ssh user@device "exit";`
Consider using threads or jobs to run your connections in parallel. This could speed things up significantly!
You might want to try using SSH with the option `-o StrictHostKeyChecking=accept-new` or `-o StrictHostKeyChecking=no`. This should help you bypass the host key checks and let you connect without issues.
This is a good call! Honestly, forget about PuTTY and PLINK; they’re pretty outdated at this point.

I tried both methods in a loop, and they still just hang. It’s so frustrating!