配置完ssh公钥之后,一直不能自动登录,发现被登录主机的.ssh目录是手动建立的,没有ssh_home_t标签。
问题已解决:是因为.ssh目录没有ssh_home_t
标签!!通过下面命令重置。
restorecon -r -vv /root/.ssh
[root@localhost ~]# restorecon -r -vv .ssh
restorecon reset /root/.ssh context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:ssh_home_t:s0
restorecon reset /root/.ssh/id_rsa context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:ssh_home_t:s0
restorecon reset /root/.ssh/known_hosts context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:ssh_home_t:s0
restorecon reset /root/.ssh/authorized_keys context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:ssh_home_t:s0
restorecon reset /root/.ssh/id_rsa.pub context unconfined_u:object_r:admin_home_t:s0->unconfined_u:object_r:ssh_home_t:s0
通过这个命令查看文件夹或文件的标签
或者使用ssh-keygen –t rsa –P自动创建.ssh文件夹。