bash ssh 脚本给出“key_read”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2492463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ssh script gives "key_read" error
提问by lugte098
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.
我使用的脚本通过 ssh 连接到集群并发送一些命令,然后退出连接。这个脚本基本上使用ssh连接一次,然后在这个会话中执行一个脚本。该脚本会在命令列表中循环几次,并在完成后终止连接。
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.
所以这个脚本工作正常,除了几个循环后它在循环 22 给我以下错误。然后在循环 32 再次。循环做完全相同的事情,所以我无法理解脚本面临的问题. 我认为这个脚本不可能在每次他必须运行一个循环时都要求进行身份验证。
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==
采纳答案by Dan
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.
您可能正在处理一些超时问题...尝试在脚本中添加睡眠以使循环花费更长的时间,看看它是否仍然在循环 22 和 32 时停止...这可能只是这些循环发生的时间. 如果是这种情况,您可能需要对您登录的服务器上的 sshd 配置文件进行调整(如果您有访问权限),否则您始终可以添加到本地计算机上的 ssh 配置中。像“ServerAliveInterval 5”这样的东西可能会有所帮助。
回答by Pol
Another reason why this problem can happen:
可能发生此问题的另一个原因:
I had a similar issue while SSHing to one of our servers: it would work but display this strange error message. The solution was actually to fix the ~/.ssh/known_hosts which had 2 entries for this server.
我在通过 SSH 连接到我们的一台服务器时遇到了类似的问题:它可以工作,但会显示这个奇怪的错误消息。解决方案实际上是修复 ~/.ssh/known_hosts 这个服务器有 2 个条目。
回答by Chris Moschini
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.
我将我的 id_rsa.pub 内容从 Windows 粘贴到 Linux VM 中。这导致 CRLF 被插入到行中间的几个地方,这只有在我用足够宽的窗口编辑文件时才明显(或者在足够宽的终端中编辑)。删除 CRLF 使整个事情都在一行上解决了这个问题。
回答by WolfieZero
Hopefully this might help a few people.
希望这可以帮助一些人。
I had this exact error message when SSHing to any server. The interesting thing was that I was allowed access still. I checked all the SSH key files and they where all on a single line (which a lot of people reported as a possible cause).
当通过 SSH 连接到任何服务器时,我收到了这个确切的错误消息。有趣的是,我仍然被允许访问。我检查了所有 SSH 密钥文件,它们都在一行中(很多人报告说这是一个可能的原因)。
Then I removed the comment from the RSA public(== [email protected]) and it worked! I then removed that line from the DSA public; the error popped up again.
然后我从 RSA public( == [email protected]) 中删除了评论并且它起作用了!然后我从 DSA 公众号中删除了这条线;错误再次弹出。
I'm not that knowledgable on SSH keys and how they work exactly, but this seems to have done the trick for a number of servers I access. So remove the comment from RSA public and leave it in for the DSA public.
我对 SSH 密钥以及它们的工作原理不太了解,但这似乎对我访问的许多服务器都起到了作用。因此,从 RSA public 中删除评论并将其保留给 DSA public。
回答by joar
For me it was a error in the ~.ssh/known_hostsfile in my .sshfolder. I deleted all lines to get a "fresh" start of known hosts, and I got no errors after this.
对我来说,这是~.ssh/known_hosts我.ssh文件夹中的文件错误。我删除了所有行以获得已知主机的“全新”启动,此后我没有出现任何错误。
回答by Kenny Evitt
For me, I had a public key for one server spread over multiple lines due to copypasta. Putting the entire key onto a single line resolved this error.
对我来说,由于 copypasta,我有一个分布在多行上的服务器的公钥。将整个密钥放在一行上解决了这个错误。
回答by SDGuero
I saw this online: http://support.bb4.com/archive/200408/msg00235.html
我在网上看到这个:http: //support.bb4.com/archive/200408/msg00235.html
Looked similar to your problem. There is another link in the post to more detailed info on Big Brother's website.
看起来和你的问题很相似。帖子中有另一个链接,可以在老大哥的网站上找到更详细的信息。

