ssh配置authorized_keys后仍然需要输入密码的问题
前阵子搭建Hadoop时,配置了本机(localhost)的ssh的公钥到authorized_keys文件中,但是在ssh连接localhost时仍然提示需要输入密码,后来发现是$HOME/.ssh/authorized_keys这个文件的权限问题引起的。其原因是,不能让所有者之外的用户对authorized_keys文件有写权限,否则,sshd将不允许使用该文件,因为它可能会被其他用户篡改。
命令行的演示如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[hadoop@guest1 ~]$ cd .ssh/[hadoop@guest1 .ssh]$ ll total 16 -rw-rw-r-- 1 hadoop hadoop 395 Jan 1218 : 37 authorized_keys -rw------- 1 hadoop hadoop 1675 Jan 1218 : 36 id_rsa -rw-r--r-- 1 hadoop hadoop 395 Jan 1218 : 36 id_rsa.pub -rw-r--r-- 1 hadoop hadoop 796 Jan 6 08 : 40 known_hosts #注意这里的authorized_keys文件的权限;这时该文件中的key是不起作用的。#用chmod修改authorized_keys文件的权限[hadoop@guest1 .ssh]$ chmod g-w authorized_keys [hadoop@guest1 .ssh]$ ll total 16 -rw-r--r-- 1 hadoop hadoop 395 Jan 1218 : 37 authorized_keys -rw------- 1 hadoop hadoop 1675 Jan 1218 : 36 id_rsa -rw-r--r-- 1 hadoop hadoop 395 Jan 1218 : 36 id_rsa.pub -rw-r--r-- 1 hadoop hadoop 796 Jan 6 08 : 40 known_hosts #修改后,sshd就可以正常使用authorized_keys文件了[hadoop@guest1 ~]$ ssh localhost Last login: Sat Jan 1218 : 40 : 332013 from localhost [hadoop@guest1 ~]$ exitlogout Connection to localhost closed. [hadoop@guest1 ~]$ |
后来,我详细查了一下,如果authorized_keys文件、$HOME/.ssh目录 或 $HOME目录让本用户之外的用户有写权限,那么sshd都会拒绝使用 ~/.ssh/authorized_keys 文件中的key来进行认证的。
“man sshd”命令查看对authorized_keys文件的描述如下:
1
2
3
4
5
6
7
8
9
10
11
|
man sshd ..... ~/.ssh/authorized_keys Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in as this user. The format of this file is described above. The content of the 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”. ........ |
ssh配置authorized_keys后仍然需要输入密码的问题的更多相关文章
- Hadoop集群搭建(cluster setup),ssh免密后一直要求输入密码的原因
前段时间,网上有言SHA-1加密技术,已经被谷歌公司破解,在linux系统中,集群间加密的技术是用DSA秘钥,秘钥本身其实是一种算法,就像前面说的SHA-1也是加密算法的一种. 免密在linux系统中 ...
- ssh复制公钥成功后仍需输入密码
1,网上说权限问题 登录流程: 被登录机器的文件权限: //用户权限 chmod 700 /home/username //.ssh文件夹权限 chmod 700 ~/.ssh/ // ~/.ssh/ ...
- ssh-keygen的使用方法及配置authorized_keys两台linux机器相互认证
一.概述 1.就是为了让两个linux机器之间使用ssh不需要用户名和密码.采用了数字签名RSA或者DSA来完成这个操作 2.模型分析 假设 A (192.168.20.59)为客户机器,B(192. ...
- SSH配置免秘钥登录
一. SSH 配置免秘要登录 配置SSH 免秘要登录,虽然就那么几步,但总是会出现点小问题,今天就做下记录.SSH 免秘钥就是让两台机器相互信任,不需要输入密码就能相互登录.配置相互信任就是把各自的 ...
- ssh配置含义解释
ssh包括客户端配置(ssh_config)和服务端配置(sshd_config) 一.客户端配置ssh_config,客户端软件有SecureCRT.putty.Xshell等 “#”表示注释,虽然 ...
- jenkins自动化部署项目5 -- 系统管理-系统设置ssh配置
[系统管理]-[系统设置] 如果应用服务(前端后台)要部署在linux服务器上,我选择的是用ssh 为了jenkins登录远程登录linux服务器可以免密登录,先配置公钥和私钥: 我是在windows ...
- CentOS SSH配置
默认CentOS已经安装了OpenSSH,即使你是最小化安装也是如此.所以这里就不介绍OpenSSH的安装了. SSH配置: 1.修改vi /etc/ssh/sshd_config,根据模板将要修改的 ...
- github SSH配置
目录 github SSH配置 前言 ssh 配置 github SSH配置 前言 github有两种更新的渠道,一种是https的,一种是ssh的,其中https每次都要输入密码,非常烦.所以,最好 ...
- mysql+ssh 配置(转载)
Mysql+ssh配置 一.Linux平台间mysql+ssh配置 本机地址为:192.168.189.133 mysql服务器地址为:192.168.189.139 linux命令行下使用ssh命令 ...
随机推荐
- C#获取外网IP地址;C#获取所在IP城市地址
public static string GetIP() { using (var webClient = new WebClient()) ...
- angularjs中使用$q.defer
方法method1和方法method2的区别,我还正在研究中...待添加 代码如下: <html ng-app="myApp"> <head> <ti ...
- eclipse中android开发怎么修改xml文件字体大小
windows->preference->General->appearence->Colors and Font->Basic->Text Font.点击右侧的E ...
- wap、app移动端页面常用html标签汇总
1.section 将内容组织到精确的语义块,表示页面的一部分. 2.article article表示网页的一个文章.故事. 3.header (1)用在整页的页头 (2)section或者arti ...
- MVC中cshtml文件中怎样使用ViewBag进行筛选?
@foreach (PermissionForRoleModel item in ((List<PermissionForRoleModel>)ViewBag.PermissionsFor ...
- docker sshd image problem, session required pam_loginuid.so, cann't login
在使用sshd docker 镜像时, 发现一个比较诡异的问题, 有些启动的容器可以连接, 有些不能. 例如 : 启动2个容器(这两个容器都有问题) : [root@localhost ~]# d ...
- FFmpeg采集音视频数据命令
文章转自:https://www.jianshu.com/p/4709ccbda3f9 1.ffmpeg 把文件当做直播推送至服务器 (RTMP + FLV) ffmpeg - re -i demo. ...
- VLC命令行参数详解
VLC命令行参数详解 2012-11-29 14:00 6859人阅读 评论(0) 收藏 举报 Usage: vlc [options] [stream] ...You can specify mul ...
- python笔记-列表和元组
列表和元组: -可以将列表和元组当成普通的数组 -列表和元组可以保存任意类型的python对象 -通过从0开始的数字索引访问元素 -列表和元组可以存储不同类型的对象 列表和元组的区别: -列表元素使用 ...
- 从pdf 文件中抽取特定的页面
前段时间买了一个kindle 电子书阅读器.我想用它来读的pdf文档.当然最主要是用来读python标准库&mysql的官方文档. 问题就来了.这两个都是大头书.之前用mac看还好.用kind ...