SSH错误:“不是RSA1密钥文件~/.ssh/id_rsa。”,“key_type_from_name:未知的密钥类型'-----BEGIN'”

10
git push heroku master

返回:

ssh_exchange_identification: read: Connection reset by peer      
fatal: The remote end hung up unexpectedly.

这是我第一次尝试推送到Heroku。

  • heroku login 返回 "认证成功"。
  • ~/.ssh/id_rsa 最初是由Heroku命令行客户端创建的-我第一次运行heroku login时,它询问是否要生成密钥。
  • 我按照这里的说明重新使用ssh-keygen -t rsa创建了密钥,但仍然没有成功。
  • 在 "~/.ssh" 创建了 "authorized_keys" 文件,并将我的公钥放入其中,但仍然没有成功。
  • 创建了包含内容 "sshd all" 的 /etc/hosts.allow 文件,但仍然没有成功。

密钥权限为:"-rw-------" Heroku状态良好。 我使用的是Mac OS X 10.7。

ssh -vvv myloginname@heroku.com

返回:

OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011   
debug1: Reading configuration data /etc/ssh_config  
debug1: Applying options for *  
debug2: ssh_connect: needpriv 0   
debug1: Connecting to heroku.com [50.19.85.132] port 22.   
debug1: Connection established.   
debug3: Not a RSA1 key file ~/.ssh/id_rsa.   
debug2: key_type_from_name: unknown key type '-----BEGIN'   
debug3: key_read: missing keytype    
debug3: key_read: missing whitespace   
debug3: key_read: missing whitespace   
debug3: key_read: missing whitespace    
debug3: key_read: missing whitespace   
debug3: key_read: missing whitespace   
debug3: key_read: missing whitespace  
debug3: key_read: missing whitespace   
debug3: key_read: missing whitespace   
debug3: key_read: missing whitespace   
debug3: key_read: missing whitespace     
debug3: key_read: missing whitespace    
debug3: key_read: missing whitespace     
debug3: key_read: missing whitespace     
debug3: key_read: missing whitespace      
debug3: key_read: missing whitespace       
debug3: key_read: missing whitespace       
debug3: key_read: missing whitespace        
debug3: key_read: missing whitespace           
debug3: key_read: missing whitespace            
debug3: key_read: missing whitespace              
debug3: key_read: missing whitespace               
debug3: key_read: missing whitespace               
debug3: key_read: missing whitespace             
debug3: key_read: missing whitespace           
debug3: key_read: missing whitespace             
debug2: key_type_from_name: unknown key type '-----END'             
debug3: key_read: missing keytype               
debug1: identity file ~/.ssh/id_rsa type 1             
debug1: identity file ~/.ssh/id_rsa-cert type -1            
debug1: identity file ~/.ssh/id_dsa type -1            
debug1: identity file ~/.ssh/id_dsa-cert type -1               
ssh_exchange_identification: read: Connection reset by peer            

之前这个工作正常吗,然后就停止了吗?如果你运行 $ heroku login 会得到什么结果? - Schneems
不,这是我第一次尝试。而且 Heroku 登录返回“身份验证成功”。 - rishabhjain
私钥似乎已损坏或无效。文件~/.ssh/id_rsa是如何创建的? - Mark O'Connor
Heroku命令行客户端生成了它,第一次运行“heroku login”时询问是否要生成一个(我之前没有任何一个)。然后为了重新创建,我使用了“ssh-keygen -t rsa”。 - rishabhjain
你能够完成所有这些步骤吗?https://devcenter.heroku.com/articles/keys - Schneems
2个回答

3

我曾经遇到过同样的问题(不是在Heroku上),但是发生在我的自己的服务器上。

请尝试查看/var/log/auth.log,我的~/.ssh/authorized_keys文件归属于错误的用户。


-1

如果我尝试

ssh -vvv myloginname@heroku.com

我会得到这个:

debug2: key_type_from_name: unknown key type '-----END'
...
debug3: check_host_in_hostfile: filename ~/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename ~/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 2
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in ~/.ssh/known_hosts:1
debug2: bits set: 500/1024
debug1: ssh_rsa_verify: signature correct

你在~/.ssh/目录下有一个known_hosts文件吗?我的文件包含了heroku.com,50.19.85.154 ssh-rsa50.19.85.132 ssh-rsa的条目。你的文件里也有这些吗?

如果你运行which ssh-keygen,它会显示哪个版本的ssh-keygen?它是正确的版本吗?是Heroku Toolbelt安装的版本吗?如果不是,那么Heroku Managing Keys article中的步骤可能没有创建有效的密钥?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接