[CentOS] SSH 免密钥登录
一、环境说明:
操作系统:CentOS-7-x86_64-Minimal-1611
虚拟机:VMware® Workstation 12 Pro;12.5.5 build-5234757
服务器:node1(User1),node2(User2)
二、实现内容:
node1 服务器用户 User1 可通过 SSH ,免密钥登录服务器 node2 的 User2 账户;

三、配置流程:
默认情况下,node1 上的用户 User1 想连接 node2,需要输入密码,如下:
[User1@localhost ~]$ ssh User2@node2
The authenticity of host 'node2 (192.168.126.141)' can't be established.
ECDSA key fingerprint is 0c:f2:1d:5b:0a:ea:38:43:e7:d2:07:28:d8:05:8a:d6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node2,192.168.126.141' (ECDSA) to the list of known hosts.
User2@node2's password:
Last login: Fri Feb 2 17:03:45 2018
1、现在通过用户 User1 在 node1 的 /home/User1 目录下生成一对公钥和私钥:
[User1@localhost ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/User1/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/User1/.ssh/id_rsa.
Your public key has been saved in /home/User1/.ssh/id_rsa.pub.
The key fingerprint is:
ff:cc:0e:22:aa:79:54:d3:15:90:bd:98:2b:26:e1:35 User1@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
| .+.. |
| . o |
| . + . |
| . E + . |
| . + oS. |
| + o .. |
| . o... o |
| ... . . = |
| oo. .= |
+-----------------+

2、然后将公钥上传给 node2 的 User2 用户:
[User1@localhost ~]$ ssh-copy-id User2@node2
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
User2@node2's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'User2@node2'"
and check to make sure that only the key(s) you wanted were added.
3、登录验证成功:

说明:
1、此时 node1 上用户 User1 的私钥文件内容(id_rsa.pub)会追加到 node2 上用户 User2 的 ~/.ssh/authorized_keys 文件中:


2、还可以通过 scp 命令,将 node1 服务器上的公钥拷贝到 node2 服务器上,然后追加到 ~/.ssh/authorized_keys,
scp ~/.ssh/id_rsa.pub User2@node2:~/
3、还可以通过 cat 命令直接追加:
cat ~/.ssh/id_rsa.pub | ssh -P 22 User2@node2 'cat >> ~/.ssh/authorized_keys'
[CentOS] SSH 免密钥登录的更多相关文章
- linux系统ssh免密钥登录配置
linux主机配置ssh免密钥登录,具体配置如下: 1.执行命令ssh-keygen -t rsa,生成公钥和私钥(具体步骤详见下图) 2.会在当前用户的家目录的.ssh/生成公钥和私钥, 3.执行s ...
- Linux机器之间SSH免密钥登录设置
SSH免密钥登录 私钥:密钥留在本机 公钥:密钥发给其他机 hadoop01 生成密钥: ssh-keygen -t rsa (密钥存放路径:/root/.ssh) id_rsa:私钥 id_rsa. ...
- 014-配置SSH免密钥登录
问题:client端需要免密钥登录服务器server如何配置?1.前提:客户端已安装openssh-client;服务端已安装openssh-server;服务器端22号端口已经打开2.需要密钥登录时 ...
- centos ssh 免密码登录
最近在学习的过程中遇到这个问题: A主机和B主机: A 免密码登录B: 首先在A的 ~/.ssh 目录中 执行 ssh-keygen -t rsa 一路回车 最后生成连个文件: 将id_rsa.pub ...
- ssh免密钥登录一例问题
今天遇到一个奇怪的问题,在同一机器上创建的普通用户使用 ssh-copy-id -i .ssh/id_rsa.pub root@192.168.3.254 建立与root用户的免密钥通信,结果死活还是 ...
- ssh免密钥登录
说明:下文中说的 '客户端'指的是你所使用的本地机器; '服务端'指的是远程你要连接的机器; ----------------------------------------------------- ...
- linux配置ssh免密钥登录
https://blog.csdn.net/xiaoyi23000/article/details/80597516 1.执行命令ssh-keygen -t rsa,生成公钥和私钥 2.会在当前用户的 ...
- Centos6.5之ssh免密码登录配置
Centos6.5之ssh免密码登录配置 centos ssh 免密码登录 0.说明 这里为了方便说明问题,假设有A和B两台安装了centos6.5的主机.目标是实现A.B两台主机分别能够通过ssh免 ...
- 在CentOS/RHEL上设置SSH免密码登录
本文会告诉你怎样在 CentOS/RHEL 上设置 SSH 免密码登录.自动登录配置好以后,你可以通过它使用 SSH (Secure Shell)和安全复制 (SCP)来移动文件. SSH 是开源的, ...
随机推荐
- VxWorks 符号表
符号表初始化 符号表用于建立符号名称.类型和值之间的关系.其中,名称为null结尾的任意字符串:类型为标识各种符号的整数:值为一个字符指针.符号表主要用来作为目标模块加载的基础,但 ...
- org.hibernate.engine.jndi.JndiException:Error parsing JNDI name[foo]
1.错误描述 WARN:HHH00027:Could not bind factory to JNDI org.hibernate.engine.jndi.JndiException:Error pa ...
- RHEL64 缺少ISO 9660图像 安装程序试图挂载映像#1,在硬盘上无法找到该映像
用光盘安装Linux,很容易,按照提示一步一步就好.如果没有光驱,只好想办法用硬盘或者U盘安装了. 首先说说怎样用U盘启动Linux的安装程序:1.将ISO镜像文件拷贝到U盘中,并解压到U盘根目录.将 ...
- windows驱动程序wdf--KMDF大致框架
继WDM后微软出了WDF,封装了WDM中的一些基本代码逻辑.本人菜鸟,也不知道本质上有何区别,只觉得是多了Wdf开头的函数,基本的编程框架上有点出入. KMDF是WDF的内核级部分,为了理清KMDF的 ...
- ubuntu14.04 64位 安装eclipse出错
1 错误描述 org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was a ...
- 求助:关于sql如何统计时间的问题
三.现在我们假设应用计时分为app应用和web应用,需要考虑如下几个方面: (1)多时间段(2)表中有冗杂数据 (3)用户是在web端和app端都登陆,这种类型的重复时间段只能取其一 存在数据: 存在 ...
- CASE WHEN用法
问题:假如说这个条件有一条数据不满足,那么那条数据就不会读出来,,那么,我怎么才能把它读出并且赋值为空呢 方法: SELECT `s`.*, ( CASE THEN SUM(a.total_numbe ...
- 关于 CI框架访问数据库类提示Call to undefined function mysqli_init() 问题解决
我上次实践发现,安装在Win10 WampServer3.0.4集成环境,不仅打不开phpmyadmin会报错就算了,而且报错后又没提示那么解决,同时你打开php扩展配置发现,WampServer系统 ...
- 云计算之路-阿里云上:3个manager节点异常造成 docker swarm 集群宕机
今天 11:29 - 11:39 左右,docker swarm 集群 3 个 manager 节点同时出现异常,造成整个集群宕机,由此给您带来很大的麻烦,请您谅解. 受此次故障影响的站点有:博问,闪 ...
- 如何直接在github上预览html网页效果
http://justcoding.iteye.com/blog/2321552 2.vue 配合vue-resource调用接口,获取数据 https://www.cnblogs.com/fei ...