您的位置:首页 > 运维架构 > Linux

linux公钥私钥互联

2017-12-13 17:14 197 查看
#生成ssh配置文件
ssh root@192.168.224.131
The authenticity of host '192.168.224.131 (192.168.224.131)' can't be established.
RSA key fingerprint is SHA256:TV36UOt/YfJSnHokQucICAjymOh4tGiO7S7VkGsJGwk.
RSA key fingerprint is MD5:7e:8f:22:97:2b:6d:bc:db:ed:e5:5d:fd:a5:ff:2f:f3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.224.131' (RSA) to the list of known hosts.
root@192.168.224.131's password:
Last login: Sat Nov 25 13:08:05 2017 from 192.168.224.1

cat known_hosts
192.168.224.131 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxd7AHPak0PJYjYoW86dxJfvUT7j7DJnZIqbhegYAfVPyWejTvLsZVr8VF/xPJuaZ9+OvcF+NKoWFRPEEVooL5SyEqYohM0T7Iu0gLEq8HIzjIekIFEBVGIi2Dn2Uuyj0qwQcIa5G4e/S8/yTc/2nmU78hKLuxvBYaTpNlDDunMYBuFkkaAnfBHIwnx69c6JAwkTttcPPBTqD5VL/mzGFIXTH3uVXDb9StxUtWeBf549N3gW3SYpkkorIlMpwIdrhpbjMiIaO4StfUyDLpA/6J9Mv7LVWbz/cmEE4+/cz34VgaDl67HWy5WE3jXJpDuQw+5uJ3aMUzmtM2NsIE48UDw==

#生成公私玥
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:OEWz465L9PjLF77AlWCOYWaBqr7gIA3htDaD1pFWbjs root@liyanan_python
The key's randomart image is:
+---[RSA 2048]----+
|    o. o        |
|    =  o o      |
9da2

|.. = o= *        |
|+.= o+.O o .    |
|oO . E= S o      |
|+oo  ..* ..      |
|= .  o =. .    |
|=.  . + .o      |
| o.  o.+o..    |
+----[SHA256]-----+

cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGvuLPbBoL1N+Q4ZOaQe8mrVt/dS5WyxivWf0mQ2Y1Aj3wC7SEvRdRad3z/QLDTjVTS/uDDEL3Ol/vo0UtzGVink5hw86c5YZ8ZRyUdZ56bBqi1ZOcpd4sAg0GOQ+2N1pvxikm5lv42K8JrjZhAp2mCvb+t5AcQb3XTJvIgATsBKQXCIziUC/X0FcVzXj4ouPQWtw2PMGFJlfKk/H2D5QhK86qsQXUIRrRmQ67gsV7NpkjfWKznucZxLDdhzooLHNBpzfA72r9ojvB0r1g08qmhmtngZ7/JaG6qaQ1g6l7Mts1Xlz8t4QMY1p4bPiXLdkIa8a05d2M3tG4+8opeeqv root@liyanan_python

#发送公钥给对方
ssh-copy-id "liyanan@192.168.224.131"
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/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: WARNING: All keys were skipped because they already exist on the remote system.
(if you think this is a mistake, you may want to use -f option)

#无密码登陆
[root@liyanan_python .ssh]# ssh liyanan@192.168.224.131
Last login: Sat Nov 25 13:51:41 2017 from 192.168.224.129
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: