与 Heroku 帐户的 SSH 连接失败
Posted
技术标签:
【中文标题】与 Heroku 帐户的 SSH 连接失败【英文标题】:SSH Connectivity to Heroku account fails 【发布时间】:2020-03-29 22:16:44 【问题描述】:尝试配置 Herokugit,接受默认密钥 (id_rsa) 作为公钥,将权限更改为 600,因为它抱怨它不安全。现在,当我尝试验证 ssh 连接时,我收到无效的文件格式错误。
[coderhub@Coderhub-mac heroku]$ssh -v git@heroku.com
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/coderhub/.ssh/config
debug1: /Users/coderhub/.ssh/config line 1: Applying options for heroku.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to heroku.com port 22.
debug1: Connection established.
debug1: identity file /Users/coderhub/.ssh/id_rsa.pub type 0
debug1: identity file /Users/coderhub/.ssh/id_rsa.pub-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version endosome
debug1: no match: endosome
debug1: Authenticating to heroku.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:8tF0wX2WquK45aGKs/Bh1dKmBXH08vxUe0VCJJWOA/o
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /Users/coderhub/.ssh/known_hosts:33
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /Users/coderhub/.ssh/id_rsa.pub RSA SHA256:suGiIhQN6QphoPJwM4YecZDiTRjNZIPHh46ur58TbvA explicit
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/coderhub/.ssh/id_rsa.pub RSA SHA256:suGiIhQN6QphoPJwM4YecZDiTRjNZIPHh46ur58TbvA explicit
debug1: Server accepts key: /Users/coderhub/.ssh/id_rsa.pub RSA SHA256:suGiIhQN6QphoPJwM4YecZDiTRjNZIPHh46ur58TbvA explicit
**Load key "/Users/coderhub/.ssh/id_rsa.pub": invalid format**
debug1: No more authentication methods to try.
git@heroku.com: Permission denied (publickey).
【问题讨论】:
“加载密钥”/Users/coderhub/.ssh/id_rsa.pub“:格式无效”——您的公钥显然无效。你是如何创建它的? $ssh-keygen -t rsa 【参考方案1】:可能是SSH key format issue。
尝试使用旧的 PEM 格式(私钥 id_rsa 中的 64 个字符宽)而不是新的 OpenSSH 格式(70 个字符宽)重新生成它
ssh-keygen -m PEM -t rsa -P ""
(覆盖您现有的密钥——如果你不在其他任何地方使用它——并在 Heroku 上注册公共密钥)
如评论所述,请仔细检查您的 /Users/coderhub/.ssh/config
内容:
heroku.com
条目中的IdentityFile
行应该引用私钥id_rsa
,不是公钥id_rsa.pub
。
我在“Unable to ssh using git config file”中有详细说明。
【讨论】:
你在什么操作系统上? ssh 的版本是多少? ssh-keygen? Mac OS Mojave 10.14 SSH-OpenSSH_7.9p1,LibreSSL 2.7.3 @Vikram OK 所以格式是相关的。您是否在 Heroku 端注册了公钥? (devcenter.heroku.com/articles/keys) 我怀疑另一个问题:***.com/a/57917551/7976758 @Vikram 你能检查你的 /Users/coderhub/.ssh/config 内容吗?我已经编辑了答案。以上是关于与 Heroku 帐户的 SSH 连接失败的主要内容,如果未能解决你的问题,请参考以下文章
iPhone 与本地网络上的 Raspberry Pi 的 SSH 连接失败