Linux ssh免密码认证

简介:

[root@localhost ~]# ssh-keygen -t rsa #创建密钥对

Generating public/private rsa key pair

Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
e0:19:93:d6:0d:fc:3f:7d:fd:b1:67:af:63:bc:d4:67 root@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
|       ..        |
|       o.o       |
|      * ...      |
|     o =  .      |
|      o S  . .  .|
|            o .oo|
|             o..E|
|             .+o=|
|             .o=+|
+-----------------+
[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@10.0.0.20 #部署公钥到KVM服务器

The authenticity of host '10.0.0.20 (10.0.0.20)' can't be established.
ECDSA key fingerprint is c3:a2:bc:39:7d:a5:fd:f5:8a:93:28:fd:e6:4c:29:7b.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@10.0.0.20's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@10.0.0.20'"
and check to make sure that only the key(s) you wanted were added.

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@10.0.0.30 #部署公钥到KVM服务器

The authenticity of host '10.0.0.30 (10.0.0.30)' can't be established.
ECDSA key fingerprint is c3:a2:bc:39:7d:a5:fd:f5:8a:93:28:fd:e6:4c:29:7b.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@10.0.0.30's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@10.0.0.30'"
and check to make sure that only the key(s) you wanted were added.

[root@localhost ~]# 

[root@localhost ~]# ssh 10.0.0.20 #测试登陆服务器
Last login: Tue May 16 22:27:43 2017 from controller

[root@localhost ~]# ssh 10.0.0.30 #测试登陆服务器

Last login: Tue May 16 22:28:11 2017 from controller


本文转自 gswljy 51CTO博客,原文链接:http://blog.51cto.com/guoshiwei/1926443

相关文章
|
2月前
|
安全 Linux Shell
Linux中SSH命令介绍
Linux中SSH命令介绍
54 2
|
5天前
|
Linux 网络安全 Python
Linux离线安装Python时ssh和hashlib死活安装不上的解决方案
本文提供了Linux环境下离线安装Python时遇到的"ImportError: No module named _ssl"和"ERROR:root:code for hash md5|sha1|sha224|sha256|sha384|sha512 was not found"两个问题的解决方案,通过设置OpenSSL环境变量和编辑Python源码配置文件来解决。
9 1
|
15天前
|
安全 Shell 网络安全
告别繁琐密码,一键解锁GitHub高效秘籍!SSH配置大揭秘,让你的代码托管之旅飞起来!
【8月更文挑战第4天】在使用GitHub时,频繁输入账号密码颇为不便。采用SSH协议可提升安全性并简化流程。本文以问答形式指导你快速配置GitHub SSH:了解SSH优势、学会生成与添加SSH密钥及测试连接。通过简单的步骤,即可实现无缝代码推送与拉取,享受高效、安全的开发体验。记得保护好私钥并根据需要设置多个密钥对。
30 7
|
2天前
|
存储 安全 Linux
说到Linux安全,SSH限制IP登录绕不开这3种方法!
说到Linux安全,SSH限制IP登录绕不开这3种方法!
|
5天前
|
安全 Linux Shell
如何在 Linux 服务器上配置基于 SSH 密钥的身份验证
如何在 Linux 服务器上配置基于 SSH 密钥的身份验证
11 0
|
7天前
|
Linux 网络安全 数据安全/隐私保护
Linux——配置SSH免密登录
Linux——配置SSH免密登录
17 0
|
23天前
|
安全 Ubuntu Linux
记录一次Linux服务器被人使用SSH字典爆破
曾经我以为互联网到至今应该是很和平的状态,但是经历了这次ssh字典爆破攻击后我才意识到网络攻击无处不在,建议系统密码使用比较复杂的随机字符组合,七八十位都没问题,数据可贵,电脑该装杀毒软件的就装上,别因为那占用那点内存而舍弃杀毒软件,防网络攻击于未然 !
|
2月前
|
网络协议 Linux 网络安全
Linux配置SSH允许TCP转发
Linux配置SSH允许TCP转发
32 1
|
1月前
|
网络安全 数据安全/隐私保护
服务器密码登录出现了:SSH connection failed: connect ECONNREFUSEDxxxxxxxx:22 * Xshell提示 SSH connection fa
服务器密码登录出现了:SSH connection failed: connect ECONNREFUSEDxxxxxxxx:22 * Xshell提示 SSH connection fa
|
1月前
|
安全 Linux 网络安全
ssh中的密码登录和密钥登录
ssh中的密码登录和密钥登录