为什么SSH需要一个密码短语的密码短语?

我有一个不使用密码的SSH密钥。 我想在构buildDocker容器时使用该键来获取私有的git存储库。

我成功设法在构build时将密钥放入容器,但是现在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(至less有一些版本)在任何时候都会提示input密码,这样就无法使密钥文件变得有意义:

 $ 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':