2013-03-07 27 views
5

khách hàng: Mac 10.8, server: Ubuntu 10.04 LTS 64bitssh không thể sử dụng cấu hình IdentityFile trong file ~/.ssh/config

tôi sử dụng 'ssh-keygen -t rsa' tạo khóa công khai/riêng.

Trước tiên, tôi đầu vào: ssh -i /Users/phenix/.ssh/poponet_rsa [email protected], tôi có thể đăng nhập vào máy chủ với khóa riêng 'poponet_rsa'

Tiếp theo, tôi tạo một tập tin cấu hình: /Users/phenix/.ssh/config, với nội dung:

Host popo 
    Hostname popo.net 
    User root 
    PreferredAuthentications publickey 
    IdentityFile /Users/phenix/.ssh/poponet_rsa 

và tôi đầu vào ssh [email protected], nhà ga hỏi tôi mật khẩu.

Tiếp theo, tôi thay đổi poponet_rsa filename để id_rsa, và đầu vào ssh [email protected], OK, tôi đăng nhập.

Câu hỏi của tôi: ssh không thể sử dụng cấu hình IdentityFile trong tệp ~/.ssh/config, tại sao?

$ ssh -vvv [email protected] 
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011 
debug1: Reading configuration data /Users/phenix/.ssh/config 
debug1: /Users/phenix/.ssh/config line 1: Applying options for popo.net 
debug1: /Users/phenix/.ssh/config line 2: Applying options for popo.net 
debug1: Reading configuration data /etc/ssh_config 
debug1: /etc/ssh_config line 20: Applying options for * 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to popo.net [111.111.111.111] port 22. 
debug1: Connection established. 
debug3: Incorrect RSA1 identifier 
debug3: Could not load "/Users/phenix/.ssh/id_rsa" as a RSA1 public key 
debug1: identity file /Users/phenix/.ssh/id_rsa type -1 
debug1: identity file /Users/phenix/.ssh/id_rsa-cert type -1 
debug1: identity file /Users/phenix/.ssh/id_dsa type -1 
debug1: identity file /Users/phenix/.ssh/id_dsa-cert type -1 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1 Debian-3ubuntu7 
debug1: match: OpenSSH_5.3p1 Debian-3ubuntu7 pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_5.9 
debug2: fd 3 setting O_NONBLOCK 
debug3: load_hostkeys: loading entries for host "popo.net" from file "/Users/phenix/.ssh/known_hosts" 
debug3: load_hostkeys: found key type RSA in file /Users/phenix/.ssh/known_hosts:1 
debug3: load_hostkeys: loaded 1 keys 
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug2: kex_parse_kexinit: **too much init, i delete them.** 
debug2: mac_setup: found hmac-md5 
debug1: kex: server->client aes128-ctr hmac-md5 none 
debug2: mac_setup: found hmac-md5 
debug1: kex: client->server aes128-ctr hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
debug2: dh_gen_key: priv key bits set: 135/256 
debug2: bits set: 468/1024 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug1: Server host key: RSA xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx 
debug3: load_hostkeys: loading entries for host "popo.net" from file "/Users/phenix/.ssh/known_hosts" 
debug3: load_hostkeys: found key type RSA in file /Users/phenix/.ssh/known_hosts:1 
debug3: load_hostkeys: loaded 1 keys 
debug3: load_hostkeys: loading entries for host "111.111.111.111" from file "/Users/phenix/.ssh/known_hosts" 
debug3: load_hostkeys: found key type RSA in file /Users/phenix/.ssh/known_hosts:1 
debug3: load_hostkeys: loaded 1 keys 
debug1: Host 'popo.net' is known and matches the RSA host key. 
debug1: Found key in /Users/phenix/.ssh/known_hosts:1 
debug2: bits set: 516/1024 
debug1: ssh_rsa_verify: signature correct 
debug2: kex_derive_keys 
debug2: set_newkeys: mode 1 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug2: set_newkeys: mode 0 
debug1: SSH2_MSG_NEWKEYS received 
debug1: Roaming not allowed by server 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug2: service_accept: ssh-userauth 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug2: key: /Users/phenix/.ssh/id_rsa (0x0) 
debug2: key: /Users/phenix/.ssh/id_dsa (0x0) 
debug1: Authentications that can continue: publickey,password 
debug3: start over, passed a different list publickey,password 
debug3: preferred publickey,keyboard-interactive,password 
debug3: authmethod_lookup publickey 
debug3: remaining preferred: keyboard-interactive,password 
debug3: authmethod_is_enabled publickey 
debug1: Next authentication method: publickey 
debug1: Trying private key: /Users/phenix/.ssh/id_rsa 
debug1: key_parse_private_pem: PEM_read_PrivateKey failed 
debug1: read PEM private key done: type <unknown> 
debug2: no passphrase given, try next key 
debug1: Trying private key: /Users/phenix/.ssh/id_dsa 
debug3: no such identity: /Users/phenix/.ssh/id_dsa 
debug2: we did not send a packet, disable method 
debug3: authmethod_lookup password 
debug3: remaining preferred: ,password 
debug3: authmethod_is_enabled password 
debug1: Next authentication method: password 
[email protected]'s password: 

Trả lời

1

Nếu bạn ~/.ssh/config là tất cả trên cùng một dòng (như bài viết của bạn gợi ý) như thế này:

Host popo Hostname popo.net User root PreferredAuthentications publickey IdentityFile /Users/phenix/.ssh/poponet_rsa 

sau đó sẽ không hoạt động. Bạn cần phải chia từng chỉ thị thành dòng riêng của mình, như sau:

Host popo 
Hostname popo.net 
User root 
PreferredAuthentications publickey 
IdentityFile /Users/phenix/.ssh/poponet_rsa 
+0

Tôi dùng thử, nhưng Nhà ga lại hỏi lại mật khẩu. Chỉ có 'debug2: key: /Users/liyuntian/.ssh/id_rsa (0x0)', và không có 'poponet_rsa' – zgia

0

Tôi không nghĩ câu trả lời đó là thực tế đối với tác giả của câu hỏi, nhưng google trả lại chủ đề này ở trang đầu tiên.

Tôi có vấn đề tương tự. Các dòng chính trong nhật ký:

debug3: Incorrect RSA1 identifier 
debug3: Could not load "/Users/phenix/.ssh/id_rsa" as a RSA1 public key 

vì vậy ssh không biết về poppet.key của bạn. Trong trường hợp của tôi là misprint trong tên tập tin.

Tôi khuyên bạn nên đặt tên cho các phím kiểm tra kép trong ~/.ssh/config.

+0

Những "lỗi" này không thực sự là vấn đề. RSA1 hiếm khi được sử dụng nữa. Điều này sẽ được hiển thị phần lớn thời gian khi một khóa được chỉ định bởi IdentityFile được nạp. – jeffcook2150

6

Tôi đã tìm thấy câu trả lời cho vấn đề của mình tại đây: https://superuser.com/a/436015.

Trong ngắn hạn, IdentitiesOnly yes cần phải được chỉ định trên máy chủ lưu trữ hoặc cấu hình máy khách SSH chung vì nếu không, cũng có thể thử các phím không xác định, bao gồm các phím trong ssh-agent.

Các vấn đề liên quan