解决ssh public key登录弹出密码输入提示
os : centos 6.x
因磁盘空间不够,将/home整个mount到一块大硬盘上,之后发现不能用普通帐号ssh登录了。新加的用户也不能使用ssh登录。root帐号一切正常。初步认定是挂载/home目录时导致的权限问题。
调试步骤:
- use root account to execute
chmod 755 /home - 新建用户test,在.ssh下添加authorized_keys,加入本机的public key。
useradd test
chmod 700 /home/test
su test
cd
mkdir .ssh
chmod 700 .ssh
add your public key to .ssh/authorized_keys
chmod 600 .ssh/authorized_keys - 用ssh -vvvT [email protected]尝试登录,查看/var/log/secure
....
Jun 18 16:32:05 test sshd[1019]: debug1: trying public key file /home/test/.ssh/authorized_keys
Jun 18 16:32:05 test sshd[1019]: debug1: restore_uid: 0/0
Jun 18 16:32:05 test sshd[1019]: Failed publickey for test from xx.xx.xx.xx port 36222 ssh2
好吧,登录失败。。。
查看/var/log/audit/audit.log,好吧,更悲剧,没有记录。。。(该问题没搞定) - 查看selinux
执行getenforce,状态为Enforcing
setenforce 0试试,再ssh -vvvT [email protected],成功了!那肯定和selinux有关了。把selinux改回来先:setenforce 1 - maybe home directory is badly labeled,恢复一下/home目录标签试试
restorecon -R -v /home
再试试ssh -vvvT [email protected],成功了!搞定
相关推荐
returnspace 2020-06-21
projava 2020-11-14
WanKaShing 2020-11-12
airfish000 2020-09-11
tryfind 2020-09-14
yegen00 2020-09-10
kkaazz 2020-09-03
风语者 2020-09-02
BraveWangDev 2020-08-19
lichuanlong00 2020-08-15
gsl 2020-08-15
pandaphinex 2020-08-09
yhuihon 2020-08-09
CheNorton 2020-08-02
xiangqiao 2020-07-28
hpujsj 2020-07-26
hpujsj 2020-07-26
sshong 2020-07-19
BraveWangDev 2020-07-19