Capture RSA fingerprint from ssh response


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture RSA fingerprint from ssh response
# 1  
Old 04-10-2009
Capture RSA fingerprint from ssh response

Hi.

I'm trying to automate access to an Amazon Web Services machine instance. What this means is that my script is trying to use ssh to connect to a new server every time. I know the RSA fingerprint of my new server through an out-of-band channel.

I would like to capture the RSA fingerprint returned by my first attempt to connect with ssh, compare with the known value, and then proceed with connection only if they match.

This is an example response from manual interaction with ssh
Code:
The authenticity of host 'notreal (123.456.78.90)' can't be established.
RSA key fingerprint is 46:1b:c6:2e:e9:63:a2:60:7c:ad:05:14:a9:93:23:da.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.

Here's what I have so far

# call ssh but decline to connect. We can parse out the RSA fingerprint
# from the response.
CHECK_FP=`ssh -t -t -i ~/.ec2/id_rsa-gsg-keypair root@$EC2_HOST 2>&1 <<EOF
no
EOF`
echo "The ssh returned fingerprint is $CHECK_FP"


Unfortunately CHECK_FP is returning "Host key verification failed", i.e. only the line after the user interaction. Also, my attempt to feed the "no" response automatically doesn't work either and I still have to enter it myself.

How can I call ssh, feeding it the correct "no" response and store the complete string from ssh for parsing?

Alternatively, is there another tool which can ask the server for the RSA fingerprint? Nothing from the ssh toolset looks appropriate.

Limitations: I'm on a small NAS linux box so installing expect and its Tcl dependencies isn't an option. Other options I've looked at involving finding the public RSA key of the server and storing it in known_hosts, but I don't think the public RSA key is available.

Thanks!

Last edited by Yogesh Sawant; 04-10-2009 at 08:23 AM.. Reason: added code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automate or 1 line command for ssh-keygen -t rsa

I know there's an echo 1 liner command that will do a new line for me, I think same with fdisk too. Dont want to press "enter,enter,enter" just to finish the ssh-keygen -t rsa. Hope you understand what i mean here. Thanks ssh-keygen -t rsa Generating public/private rsa key pair. Enter... (1 Reply)
Discussion started by: invinzin21
1 Replies

2. UNIX for Advanced & Expert Users

Need Password-Less ssh with RSA-VPN

We have RSA SecureID softtoken key generator on my Windows machine. It generates new keys every 1 minute. Any HPUX server (be it ServerD or ServerP) requires my ID and the randomly generated RSA SecureID softtoken key from my Windows to login. I login to ServerD. Then I run a script... (0 Replies)
Discussion started by: mohtashims
0 Replies

3. Shell Programming and Scripting

Capture http response code from wget

Hi All, I am using wget to call a url..i am getting 202 if it is successful. if not i am forcing the response code to 417. how can i capture the response code and print 0 if it is 202 and 1 if it is not 202 any ideas, please share Thanks, Jack. (2 Replies)
Discussion started by: jack3698
2 Replies

4. UNIX for Dummies Questions & Answers

How to change the RSA key fingerprint?

Hi there, I have a Linux Debian machine with the following fingerprint : e1:95:11:46:ff:d1:e3:4a:a3:34:1a:25:b4:d8:f1:cb. I'd like to set this fingerprint to : cd:19:bd:f6:8e:00:7a:69:14:52:a1:73:cb:15:a5:ca. I have very specific reasons to do that. So please only answer if you know how... (5 Replies)
Discussion started by: chebarbudo
5 Replies

5. Shell Programming and Scripting

RSA key fingerprint needs to be avoided.

Hi All, I need to scp a folder from one host to another in a script. When I run a command , it asks me to authenticate for the RSA key fingerprint for the first time. # scp -r temp1 root@iqcarrot:/root/ The authenticity of host 'iqmango.apac.avaya.com (148.147.172.112)' can't be... (2 Replies)
Discussion started by: nua7
2 Replies

6. Solaris

ssh and fingerprint

hello any way to avoid the fingerprint authenticity step when I ssh the first time to a server by always setting a 'yes' as a default answer? thanks (10 Replies)
Discussion started by: melanie_pfefer
10 Replies

7. Solaris

OPEN ssh with PAM &RSA

We have tested successfully OPENssh with RSA & PAM, now we have to implement this in all of our environment. In order to do this we want to integrate all the OPEN ssh packages and RSA software into one package and then just do a pkgadd of the created package and it should take care of everthing. My... (1 Reply)
Discussion started by: vishal999
1 Replies

8. UNIX for Advanced & Expert Users

ssh RSA authentication failure

I am using an ssh pub key on two remote servers to allow ssh session without authentication. Both servers have the same id_rsa.pub copied from the host into the remote servers ~user/.ssh/authorized_keys. There is no passphrase for this key either. The problem is that I am able to ssh into one... (2 Replies)
Discussion started by: prkfriryce
2 Replies

9. UNIX for Dummies Questions & Answers

Register RSA Key fingerprint with JVM 1.4.2

Hi, We wish to register RSA key fingerprint with JVM 1.4.2 under UNIX environment. Any inputs how to go for it? The output we are getting as "The authenticity of host 'sxfer01.bluecrossmn.com (159.136.224.30)' can't be established. RSA key fingerprint is... (0 Replies)
Discussion started by: asawari
0 Replies

10. Cybersecurity

ssh DSA Key fingerprint option

Hi, I have an cron-script running ssh every 5 minutes. After a reboot cron errors as ssh is wating for a DSA key fingerprint authenticy. The request looks as following : The authenticity of host '*** (*.*.*.0)' can't be established. DSA key fingerprint is... (1 Reply)
Discussion started by: davidg
1 Replies
Login or Register to Ask a Question