2017-04-11 94 views
0

我有一個使用沒有密碼一個SSH密鑰。我想使用該密鑰構建泊塢窗容器時拉一個私人的Git倉庫。爲什麼SSH需要一個密碼,按鍵少一個密碼?

我成功設法在構建時將密鑰放入容器,但現在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. 
+0

請注意,我已經嘗試用建議的方法[中加入'的/ dev/tty'這個線程](http://stackoverflow.com/a/18079668/1979736) – K40S

回答

1

你的密鑰文件可能會以某種方式損壞。 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 [email protected] 
Enter passphrase for key 'key': 
+0

這是最有可能的問題。感謝提示。 :) – K40S

+0

這確實是問題。密鑰文件中的換行符缺失。我使用另一種方法將圖片中的關鍵字修復。 – K40S