ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ssh登录基于key验证

2021-05-03 14:36:32  阅读:170  来源: 互联网

标签:10.1 登录 1.3 ssh key root id


ssh基于key验证

1,在客户端生成公钥私钥对并将公钥拷到要连接的服务器上,验证是否成功
[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): #回车,接受默认值
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:
SHA256:vpPtmqRv1llmoSvqT2Lx5C0LPGTE0pvdAqhDqlR5jLY root@centos8.wangxiaochun.com
The key's randomart image is:
[root@localhost ~]# ll .ssh/
total 12
-rw-------. 1 root root 2610 May  3 13:11 id_rsa
-rw-r--r--. 1 root root  580 May  3 13:11 id_rsa.pub
[root@localhost ~]# ssh-copy-id root@10.1.1.3 #将公钥拷贝到服务器
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '10.1.1.3 (10.1.1.3)' can't be established.
ECDSA key fingerprint is SHA256:KF7vnOMUbBsOJ17D/CI53zlfLpdetc7x93cZ4TMD/1E.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 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.1.1.3's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@10.1.1.3'"
and check to make sure that only the key(s) you wanted were added.
[root@localhost ~]# ssh 10.1.1.3 #验证成功
Last login: Mon May  3 10:35:46 2021 from 10.1.1.1
[root@route1 ~]# hostname -I
192.168.17.136 192.168.17.138 172.16.0.200 10.1.1.3 
[root@route1 ~]# exit
logout
Connection to 10.1.1.3 closed.
[root@localhost ~]# scp /etc/fstab 10.1.1.3:/root/
fstab                                                                                                            100%  615   403.3KB/s   00:00    

标签:10.1,登录,1.3,ssh,key,root,id
来源: https://www.cnblogs.com/catastrophe/p/14727377.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有