配置ssh免密登录
来源:互联网 发布:途宝网络如何设置 编辑:程序博客网 时间:2024/04/29 08:03
配置ssh免密登录:
<strong>原理解析</strong>
client A免登录到server B:
1.在A上生成公钥私钥。
2.将公钥拷贝给server B,要重命名成authorized_keys(从英文名就知道含义了)
3.client A向Server B发送一个连接请求。
4.Server B得到client A的信息后,在用户的authorized_key中查找,如果有相应的用户名和IP,则随机生成一个字符串,并用client A的公钥加密,发送给client A。
5.client A得到Server B发来的消息后,使用私钥进行解密,然后将解密后的字符串发送给Server B。Server B进行和生成的对比,如 果一致,则允许免登录。
总之:A要免密码登录到B,B首先要拥有A的公钥,然后B要做一次加密验证。对于非对称加密,公钥加密的密文不能公钥解开,只能 私钥解开
问题:
登录服务器的时候仍然要求输入密码。刚开始我以为添加ssh公钥的时候粘贴有问题,经过重新添加一次公钥后,仍然让输入密码,怀疑是~/.ssh/authorized_keys文件权限的问题。再通过查看日志,提示authorized_keys的权限错误。查看authorized_keys这个文件的权限为了664,/etc/ssh/sshd_config文件中设置有StrictModes yes 难怪添加了公钥仍然被要求输入密码
原因:
This file is not highly sensitive, but the recommended permissions are read/write for the user, and not accessible by others。If this file, the ~/.ssh directory, or the user’s home directory are writable by other users,then the file could be modified or replaced by unauthorized users. In this case, sshd will not allow it to be used unless the StrictModes option has been set to “no
将文件权限改为600
<strong>chmod 600 authorized_keys</strong>
- 配置ssh免密登录
- ssh免密登录配置
- ssh免密登录配置
- SSH免密登录配置
- SSH免密登录配置
- ssh免密登录和ssh配置
- SSH免密登录的配置
- SSH免密登录配置步骤
- Linux配置ssh免密登录
- ssh免密登录配置问题
- windows配置ssh免密登录linux
- Hadoop配置SSH免密登录
- linux配置ssh免密登录
- 配置Linux之间ssh免密登录
- linux配置ssh免密登录
- ssh 免密登录
- ssh免密登录
- SSH免密登录
- IPC之共享内存
- 第三十七讲 项目 循环嵌套
- CSS3快速上手之16:column
- 支持向量机通俗导论(二)
- 链表模板(删除模块)
- 配置ssh免密登录
- Codevs 1501 二叉树最大宽度和高度 dfs
- Space在Android里的应用
- JVM高级特性整理
- 【数据结构】算法7.10-7.11 DFS求无向图关节点
- 51nod 1624取余最长路
- 基于android的Socket通信
- Fragment碎片
- CodeForces--Platforms