免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123
最近访问板块 发新帖
楼主: smallfish
打印 上一主题 下一主题

SSH 无密码登录服务器的问题【已解决】 [复制链接]

论坛徽章:
1
丑牛
日期:2014-05-22 15:38:58
21 [报告]
发表于 2011-03-23 16:30 |只看该作者
用户目录权限是777的,authorized_keys是600

论坛徽章:
0
22 [报告]
发表于 2011-03-23 16:44 |只看该作者
回复 21# smallfish


    scpdb  换755 试试?

论坛徽章:
0
23 [报告]
发表于 2011-03-23 16:45 |只看该作者
回复 21# smallfish


    最好看看 log/secure  里相关日志 它提示的更明确

论坛徽章:
1
丑牛
日期:2014-05-22 15:38:58
24 [报告]
发表于 2011-03-23 17:02 |只看该作者
在B机器,即被连接的服务器/var/log/secure提示:
Mar 23 09:00:31 B sshd[4334]: Authentication refused: bad ownership or modes for directory /home/scpdb
Mar 23 09:00:31 B sshd[4334]: Authentication refused: bad ownership or modes for directory /home/scpdb
Mar 23 09:00:32 B sshd[4335]: Connection closed by 1.2.3.4

但是我看了下,/home/scpdb的所属用户都是scpdb,都没错啊!

论坛徽章:
0
25 [报告]
发表于 2011-03-23 17:07 |只看该作者
本帖最后由 taojie2000 于 2011-03-23 17:09 编辑

回复 24# smallfish


   目录权限 755  改了没?   
    再authorized_keys给个644试试

论坛徽章:
1
丑牛
日期:2014-05-22 15:38:58
26 [报告]
发表于 2011-03-23 17:49 |只看该作者
本帖最后由 smallfish 于 2011-03-23 17:50 编辑

问题查出来了,是用户主目录权限问题!晕死!

我换用另外一个用户:
ssh -i /home/scpdb/.ssh/id_rsa smallfish@b.com

可以的。这个用户目录权限为:
/home/smallfish  700
/home/smallfish/.ssh 700
/home/smallfish/.ssh/authorized_keys 600

然后返回来看我scpdb的权限
/home/scpdb 777(当时是为了拷贝数据方便)
/home/scpdb/.ssh  755
/home/scpdb.ssh/authorized_keys 600

只要我把/home/scpdb 改成777,从A连接过来就需要密码!如果改成700,755都没问题!关键是/home/scpdb的权限!!

所以我纳闷,为什么当时刚开始的时候是好的,前几天为了数据复制方便,把目录权限改成了777 ,没想到就出了这么个问题!花了2天时间!!!


非常感谢“taojie2000 ”!

谢谢!

论坛徽章:
0
27 [报告]
发表于 2011-11-04 16:18 |只看该作者
本帖最后由 enqihexiaoya 于 2011-11-04 16:20 编辑

帮我看看的机器的问题哇、好纠结!
OpenSSH_5.3p1 Debian-3ubuntu6, OpenSSL 0.9.8k 25 Mar 2009

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Applying options for *

debug2: ssh_connect: needpriv 0

debug1: Connecting to mac-svn[mac-svn] port 22.

debug1: Connection established.

debug1: identity file /home/xuguilian1/.ssh/identity type -1

debug3: Not a RSA1 key file /home/xuguilian1/.ssh/id_rsa.

debug2: key_type_from_name: unknown key type '-----BEGIN'

debug3: key_read: missing keytype

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug2: key_type_from_name: unknown key type '-----END'

debug3: key_read: missing keytype

debug1: identity file /home/xuguilian1/.ssh/id_rsa type 1

debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048

debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048

debug1: identity file /home/xuguilian1/.ssh/id_dsa 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.3p1 Debian-3ubuntu6

debug2: fd 3 setting O_NONBLOCK

debug1: SSH2_MSG_KEXINIT sent

debug3: Wrote 792 bytes for a total of 831

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: ssh-rsa,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,rijndael-cbc@lysator.liu.se

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,rijndael-cbc@lysator.liu.se

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib

debug2: kex_parse_kexinit: none,zlib@openssh.com,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-sha256,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-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

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,rijndael-cbc@lysator.liu.se

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: none,zlib@openssh.com

debug2: kex_parse_kexinit: none,zlib@openssh.com

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

debug3: Wrote 24 bytes for a total of 855

debug2: dh_gen_key: priv key bits set: 121/256

debug2: bits set: 499/1024

debug1: SSH2_MSG_KEX_DH_GEX_INIT sent

debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY

debug3: Wrote 144 bytes for a total of 999

debug3: check_host_in_hostfile: filename /home/xuguilian1/.ssh/known_hosts

debug3: check_host_in_hostfile: match line 1

debug1: Host '172.16.18.210' is known and matches the RSA host key.

debug1: Found key in /home/xuguilian1/.ssh/known_hosts:1

debug2: bits set: 498/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

debug3: Wrote 16 bytes for a total of 1015

debug2: set_newkeys: mode 0

debug1: SSH2_MSG_NEWKEYS received

debug1: SSH2_MSG_SERVICE_REQUEST sent

debug3: Wrote 48 bytes for a total of 1063

debug2: service_accept: ssh-userauth

debug1: SSH2_MSG_SERVICE_ACCEPT received

debug2: key: /home/xuguilian1/.ssh/id_rsa (0x7f01dad09a70)

debug2: key: /home/xuguilian1/.ssh/identity ((nil))

debug2: key: /home/xuguilian1/.ssh/id_dsa ((nil))

debug3: Wrote 64 bytes for a total of 1127

debug1: Authentications that can continue: publickey,password

debug3: start over, passed a different list publickey,password

debug3: preferred gssapi-keyex,gssapi-with-mic,gssapi,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 public key: /home/xuguilian1/.ssh/id_rsa

debug3: send_pubkey_test

debug2: we sent a publickey packet, wait for reply

debug3: Wrote 368 bytes for a total of 1495

debug1: Server accepts key: pkalg ssh-rsa blen 277

debug2: input_userauth_pk_ok: fp fe:8d:74:c4:d6:9f:28:a4:d8:a6:2f:cd:b8:47:dd:86

debug3: sign_and_send_pubkey

Agent admitted failure to sign using the key.

debug1: Trying private key: /home/xuguilian1/.ssh/identity

debug3: no such identity: /home/xuguilian1/.ssh/identity

debug1: Trying private key: /home/xuguilian1/.ssh/id_dsa

debug3: no such identity: /home/xuguilian1/.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

论坛徽章:
0
28 [报告]
发表于 2014-04-26 09:56 |只看该作者
restorecon .ssh .ssh/authorized_keys
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP