Chinaunix

标题: SSH 无法自动登录 [打印本页]

作者: LeoLiew    时间: 2009-02-07 11:39
标题: SSH 无法自动登录
在client机, 用命令ssh-keygen -t rsa 生成id_rsa.pub.
然后分别拷贝到server机的test1 和 test2 的主目录的.ssh下面, cat id_rsa.pub > authorized_keys.

现在的问题是,我在client可以顺利的用test1 SSH,却不能用test2 SSH
# ssh test1@server
#                         (不需要密码, 登录成功)

# ssh test2@server
password:           (需要密码登录)

请问:同样的操作,为什么有不一样的结果,为什么test2认证无效,需要提供密码登录?

我在server机上看了一下两个用户test1和test2的设置,唯一发现的就是他们的home directory不一样:
test1@server> cd ~
test1@server> pwd
/home/test1

test2@server> cd ~
test2@server> pwd
/app/user/test2

test2的主目录好像不是默认的主目录(被更改了),请问有可能是这样的原因吗?怎么解决(不重设主目录的情况下)?

新注册用户,暂没有积分提供,望不吝赐教。
作者: kns1024wh    时间: 2009-02-09 22:02
标题: 回复 #1 LeoLiew 的帖子
检查对方的主机的authorized_keys是否有本机的信息
作者: LeoLiew    时间: 2009-02-10 00:10
原帖由 kns1024wh 于 2009-2-9 22:02 发表
检查对方的主机的authorized_keys是否有本机的信息


大哥,怎样检查啊?我不是已经在test2用户主目录的.ssh目录下 cat id_rsa.pub > authorized_keys 了吗?
作者: LeoLiew    时间: 2009-02-10 12:12
这是部分debug log
$ ssh -vvv test2@server

.................
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,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: Trying private key: /home/dmlusr/.ssh/identity
debug3: no such identity: /home/dmlusr/.ssh/identity
debug1: Offering public key: /home/dmlusr/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/dmlusr/.ssh/id_dsa
debug3: no such identity: /home/dmlusr/.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
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: userauth_kbdint: disable: no info_req_seen
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred:
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
test2@server's password:
作者: Stout    时间: 2009-03-03 16:11
:em12: :em12:
作者: ffb    时间: 2010-06-30 17:35
你这样
cat id_rsa.pub > authorized_keys
等于把上次的认证信息覆盖了,当然另外一个就不能用了,改为

cat id_rsa.pub >> authorized_keys.
即可

或者直接用
ssh-copy-id -i id_rsa.pub IP地址
就不用自己又拷贝又cat的了
作者: JAS6oil    时间: 2010-07-07 12:08





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2