Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh script gives "key_read" error

Tags:

bash

ssh

I'm using a script that connects to a cluster through ssh and sends some commands, then quits the connection. This script basically connects once using ssh, then executes a script in this session. This script loops through a list of commands a few times and after it is finished, the connection is terminated.

So this script works fine, except for the fact that after a few loops it gives me the following error at loop 22. And then again at loop 32. The loops do exactly the same thing, so I cannot grasp the problem the script is facing. I don't think it is possible for this script to ask for authentication each time he has to run through a loop.

This is the error:

key_read: uudecode AAAAB3NzaC1yc2EAAAABIwAAAQEAxmNx2hcXLpTjuaa3yKC3B9gbF7KprP2/
CH8fBgMbCyIcOB+ZMQDmEnbVTqedBwV/mxjZzorEpHTM8MX2WsTjFsxwzDgcpuxm+3cwfb0WSy9Y4Kb
F8crAsRDbBIpUZ2n/iSdRcds9nTjk6PA61kTS24RLACHpqF18vudlO5WcbCOnAwa+DdUs0Raw29UiQc
BaC6M4YPnApq9Ayy7a6qFI2uK6efkwfLTZIDivWlIdLpRLEyuBEpozQQhEd0mrGhR/
Gl1GevRvFMms14130xQ4A5UpJSn6CmrRIWBkcgp1TilqDGQ1F5xZOinnc4C00gFrbT3hkkQqY5A9p
node023,10.141.0.31 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxmNx2hcXLpTjuaa3yKC3
B9gbF7KprP2/CH8fBgMbCyIcOB+ZMQDmEnbVTqedBwV/mxjZzorEpHTM8MX2WsTjFsxwzDgcpuxm+
3cwfb0WSy9Y4KbF8crAsRDbBIpUZ2n/iSdRcds9nTjk6PA61kTS24RLACHpqF18vudlO5WcbCOnAw
a+DdUs0Raw29UiQcBaC6M4YPnApq9Ayy7a6qFI2uK6efkwfLTZIDivWlIdLpRLEyuBEpozQQhEd0m
rGhR/Gl1GevRvFMms14130xQ4A5UpJSn6CmrRIWBkcgp1TilqDGQ1F5xZOinnc4C00gFrbT3hkkQqY5
A9pa0lQHFkSw==
like image 535
lugte098 Avatar asked Mar 22 '10 13:03

lugte098


2 Answers

I pasted my id_rsa.pub contents from Windows into a Linux VM. That caused CRLFs to be inserted in the middle of the lines in a few places, that were only obvious if I edited the file with a wide enough window (or cat'd in a wide enough terminal). Removing the CRLFs so the entire thing was on one line fixed this issue.

like image 72
Chris Moschini Avatar answered Sep 23 '22 18:09

Chris Moschini


You may be dealing with some time out issues... try adding a sleep into the script to make the loops take longer and see if it still dies on loop 22 and 32... it may just be the timing of when those loops happen. If this is the case you may have to either make adjustments to the sshd configure file on the server you're logging into (if you have access) otherwise you can always add to the ssh configuration on the local computer. Something like "ServerAliveInterval 5" may help.

like image 38
Dan Avatar answered Sep 24 '22 18:09

Dan