I would like to pass echo y
to plink.exe, so that plink execute a command.
How it can be achieved?
os.system(' c:/netapp/python/plink.exe admin@192.168.1.1 -pw xxx uptime > c:/netapp/python/12.txt')
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. The server's rsa2 key fingerprint is: ssh-rsa 2048 9d:08:37:a8:d0:34:a3:d2:d8:e5:09:7e:63:08:a9:1b If you trust this host, enter "y" to add the key to
Store key in cache? (y/n)
Do not!
Verifying host key fingerprint is an integral part of securing your connection. Blindly accepting any host key will make you vulnerable to the man-in-the-middle attacks.
Instead, use the -hostkey
switch to provide the fingerprint of the expected/known host key.
c:/netapp/python/plink.exe admin@192.168.1.1 -pw xxx -hostkey 9d:08:37:a8:d0:34:a3:d2:d8:e5:09:7e:63:08:a9:1b uptime
Confirming a server's SSH key fingerprint is an important step. This is how you know you've connected to the correct machine, and should always be done with care.
The Plink documentation makes the following suggestion:
To avoid being prompted for the server host key when using Plink for an automated connection, you should first make a manual connection (using either of PuTTY or Plink) to the same server, verify the host key (see section 2.2 for more information), and select Yes to add the host key to the Registry. After that, Plink commands connecting to that server should not give a host key prompt unless the host key changes.
来源:https://stackoverflow.com/questions/38552236/how-to-pass-echo-y-to-plink-exe-for-first-connection