LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to automatically accept ssh host key

Hello,

 

Through LabVIEW's systemexec.vi, I am using PuTTy's command line interface, plink, to access information and change settings automatically on a remote Linux computer through Secure SHell.

 

When using plink through systemexec.vi, all user prompts that are normally generated in a MS-DOS command line interface are supressed. Keep this in mind.

 

When using SSH, upon first connection you are required to verify a service host key in order to make a connection. Through plink, the command line will generate a prompt, asking the user to "accept service host key? (y/n)".

 

So my problem is that systemexec.vi will run plink, but i cant figure out a way to automatically accept the host key. All i need is for LabVIEW to recognize the prompt returned from plink and enter a "y" value.

 

Please let me know if this is confusing. I tried my best to explain my problem in a way that everyone can understand, but if I did a bad job, please allow me to rephrase myself.

 

Thank you to everyone who has any ideas at all.

0 Kudos
Message 1 of 13
(77,026 Views)

Based on the plink documentation, it looks like you can just add the -batch flag to your command line and you won't be prompted to accept the host key. 

0 Kudos
Message 2 of 13
(77,011 Views)

Thanks for the response.

 

You are correct, it does not prompt for the key. The problem is that it also doesn't accept the key. It just represses the prompt. 😛

0 Kudos
Message 3 of 13
(77,006 Views)

Can you accept the key manually and then use the LabVIEW -batch trick?

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 13
(76,998 Views)

Thank you for the response.

 

Yes, accepting the key manually possible, and is where I am at right now. But the automation program won't really be fully automated if it requires the user to do steps manually. It wont be "bad" to do it manually, but it isn't good either.

 

If, in the end, the manual option is the only way to accept the key, then I will be ok with that. I just want to try to elliminate the possiblity for error, and create more consistant results regardless of the user's level of computer experience.

 

0 Kudos
Message 5 of 13
(76,988 Views)

PuTTY should also have a way for you to add the host key to the Windows Registry.  This should either prevent the prompt entirely or allow the -batch mode to proceed with the valid key.

 

I haven't worked too much with PuTTY but for other SSH clients I've worked with, getting the right key was not too difficult and is probably the recommended method from a security perspective.

0 Kudos
Message 6 of 13
(76,977 Views)

there is a -i option to use a local file, I don't know what that means.

 

 

  -i key    private key file for authentication

 

There is a specific section in the plink manual about Automated Connections.

 

Not really helpful to me , but a question on a non-LabVIEW specific forum might be a better help point.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 7 of 13
(76,969 Views)

I don't have full solution, but I was reading this on Stackoverflow.

It's mainly about Mercurial but it points to a site on the Mercurial help page on ssh'ing.

 

It's using the following command:

plink -ssh -i "C:/path/to/key/id_rsa.ppk" -C -agent

So you need to get a private key that is accepted by the server, call plink with  the -i and the file (I'm not positive you will need forward slashes), the -Agent tells plink to use a pageant (?) and not an interatively GUI.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 8 of 13
(76,876 Views)

echo yes | plink  -agent -pw 123 -m VMinfo.sh  root@164.99.95.65

 

Above command will auto accepte certificate.

Message 9 of 13
(75,290 Views)

Hello, All

 

 

Anybody can tell me how to resolve this,thanks

 

 

Don't want to get prompt when login name with password.

 

 

 

0 Kudos
Message 10 of 13
(72,512 Views)