我有一台我经常login的服务器。 而且我必须每次input我的密码。 我想改变这个…
我已经按照教程去信了。 在服务器上,我使用ssh-keygen生成一个id_rsa *文件对。 我将.pub添加到了authorized_keys中,并检查了.ssh目录和authorized_keys文件的权限。 然后,我将id文件复制到我的家用电脑上,确认了所有的权限并进行了testing。 它没有工作。 我通过在客户端上生成密钥并将其推送到服务器再次尝试。 那也行不通。 我已经回到在服务器上生成密钥,并试图找出是什么问题…
我从客户端运行“ssh -vvv”,这里是输出(消毒):
OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012 debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: /etc/ssh_config line 53: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to SERVER [IP-ADDRESS] port 22. debug1: Connection established. debug3: Incorrect RSA1 identifier debug3: Could not load "/Users/USER/.ssh/id_rsa" as a RSA1 public key debug1: identity file /Users/USER/.ssh/id_rsa type 1 debug1: identity file /Users/USER/.ssh/id_rsa-cert type -1 debug1: identity file /Users/USER/.ssh/id_dsa type -1 debug1: identity file /Users/USER/.ssh/id_dsa-cert type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3 debug1: match: OpenSSH_4.3 pat OpenSSH_4* 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 "SERVER" from file "/Users/USER/.ssh/known_hosts" debug3: load_hostkeys: found key type RSA in file /Users/USER/.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: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,[email protected],[email protected],ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 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: 131/256 debug2: bits set: 512/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 "SERVER" from file "/Users/USER/.ssh/known_hosts" debug3: load_hostkeys: found key type RSA in file /Users/USER/.ssh/known_hosts:1 debug3: load_hostkeys: loaded 1 keys debug3: load_hostkeys: loading entries for host "IP-ADDRESS" from file "/Users/USER/.ssh/known_hosts" debug3: load_hostkeys: found key type RSA in file /Users/USER/.ssh/known_hosts:1 debug3: load_hostkeys: loaded 1 keys debug1: Host 'SERVER' is known and matches the RSA host key. debug1: Found key in /Users/USER/.ssh/known_hosts:1 debug2: bits set: 508/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/USER/.ssh/id_rsa (0x7ffc1041d270) debug2: key: /Users/USER/.ssh/id_dsa (0x0) debug3: input_userauth_banner ... debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive debug3: start over, passed a different list publickey,gssapi-with-mic,password,keyboard-interactive 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: Offering RSA public key: /Users/USER/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive debug1: Trying private key: /Users/USER/.ssh/id_dsa debug3: no such identity: /Users/USER/.ssh/id_dsa debug2: we did not send a packet, disable method debug3: authmethod_lookup keyboard-interactive debug3: remaining preferred: password debug3: authmethod_is_enabled keyboard-interactive debug1: Next authentication method: keyboard-interactive debug2: userauth_kbdint debug2: we sent a keyboard-interactive packet, wait for reply debug2: input_userauth_info_req debug2: input_userauth_info_req: num_prompts 1
我查看了服务器上的configuration(/ etc / ssh / sshd_config),我没有看到明显的原因,为什么它不起作用。 我将它与另一台已成功设置的服务器上的configuration进行了比较,唯一的区别是此服务器有一行“RSAAuthentication yes”,实际运行的服务器没有该行。
万一重要,服务器是
Linux SERVER 2.6.18-194.17.4.el5 #1 SMP Wed Oct 20 13:03:08 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
和我的客户是一个mac:
Darwin CLIENT 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
我实际上无法查看服务器上的/ var / log / secure日志文件,因为我不是此框上的pipe理员。 所以我感觉有点瞎了,难住了。
任何想法如何进行?
尝试使用ssh-copy-id将公钥复制到远程机器上。
ssh-copy-id [-i [identity_file]] [user@]machine
我不知道Mac是否有这个工具,但它在我的RHEL机器上。 这应该从authorized_keysconfiguration中删除用户configuration错误。 显然,只有在基本login工作后,才能locking授权密钥设置(from,environment等)。
您的rsa密钥在这里提供:
debug1: Offering RSA public key: /Users/USER/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive debug1: Trying private key: /Users/USER/.ssh/id_dsa
服务器日志说什么? / var / log / secure或/ var / log / auth。
该过程是在客户端上运行ssh-keygen ,然后将.ssh/id_rsa.pub (在客户端上)的内容粘贴到服务器上的.ssh/authorized_keys文件中。
有效地,你让自己成为一个关键,然后告诉服务器,你所做的密钥(由公众一半标识)被授权启动SSH会话。