我有一个不使用密码的SSH密钥。我想在构建Docker容器时使用该密钥提取私有(private)git存储库。

我成功地在构建时将密钥获取到了容器中,但是现在SSH失败了,因为它无法打开/ dev / tty来请求密钥的密码。如前所述,密钥没有密钥。

这是一些SSH输出(-v)

debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: key_load_private_type: incorrect passphrase supplied to decrypt private key
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: No more authentication methods to try.
Permission denied (publickey).
fatal: Could not read from remote repository.

最佳答案

您的密钥文件可能以某种方式损坏。 ssh(至少某些版本)会在无法理解密钥文件的任何时候提示输入密码:

$ dd if=/dev/urandom of=key bs=1500 count=1
1+0 records in
1+0 records out
1500 bytes transferred in 0.000190 secs (7893922 bytes/sec)
$ chmod 600 key
$ ssh -i key foo@localhost
Enter passphrase for key 'key':

关于git - 为什么SSH为什么需要无口令 key 的口令?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43348707/

10-11 08:34