Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Putty to SSH ignoring all warnings in Perl [duplicate]

I'm writing a Perl script to SSH into remote linux and maci machines from a windows. For that I'm running plink (putty link) command using qx. The problem is that when I try to run the plink command it gives a prompt

The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. ...... If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n)

I have to automate the process of running a command remotely. So, I somehow want to bypass this warning.

I could think of two ways of doing this but don't know how to accomplish these

  • Somehow bypass this warning from putty itself through some command line options or other commands
  • Some Perl way of passing input to plink when prompted

Can anyone suggest how to do this either in one of above ways or some other solutions.

like image 399
him Avatar asked Dec 05 '25 08:12

him


1 Answers

I solved it using pipes to pass Y to plink when prompted - echo Y | plink -ssh <user>@<host> -pw <password> <command>.

For more details refer to this answer. Also note the answer by @clay where he says

For internal servers, the blind echo y | ... trick is probably adequate (and super simple). However, for external servers accessed over the internet, it is much more secure to accept the server host key once rather than blindly accepting every time.

This was the case with me - I was using plink to ssh to internal servers.

like image 155
him Avatar answered Dec 08 '25 10:12

him



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!