客户端:mhxy162
服务端:mhxy163
服务端:mhxy163
- 在客户端生成SSH的公钥, 命令ssh-keygen,
点击(此处)折叠或打开
- [root@mhxy162 ~]# ssh-keygen
- Generating public/private rsa key pair.
- Enter file in which to save the key (/root/.ssh/id_rsa): --直接回车
- /root/.ssh/id_rsa already exists.
- Overwrite (y/n)? y --y,因为已经存在秘钥 选择y覆盖原有文件
- 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:
- 52:c6:47:45:25:a1:57:d3:76:5d:eb:76:38:f5:b9:25 root@mhxy162.cn
- The key's randomart image is:
- +--[ RSA 2048]----+
- | .o=o+.+|
- | . . . o .*|
- | + o . oo|
- | o . . .oo|
- | . S E++|
- | . .o+|
- | . |
- | |
- | |
- +-----------------+
- [root@mhxy162 ~]#
点击(此处)折叠或打开
- [root@mhxy162 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.137.163
- root@192.168.137.163's password:
- Now try logging into the machine, with "ssh 'root@192.168.137.163'", and check in:
- .ssh/authorized_keys
- to make sure we haven't added extra keys that you weren't expecting.
- [root@mhxy162 ~]# ssh 192.168.137.163 --可以通过秘钥登录
Last login: Sat May 21 23:02:39 2016 from mhxy162
[root@mhxy163 ~]#
点击(此处)折叠或打开
- [root@mhxy163 .ssh]# ll
- total 8
- -rw------- 1 root root 397 May 21 23:03 authorized_keys --秘钥登录文件
- -rw-r--r-- 1 root root 177 May 21 23:05 known_hosts --SSH登录记录的文件
- [root@mhxy163 .ssh]#
- [root@mhxy163 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyHM8Q09kQ0xg+ZhrkLto1gdUV07sLQGsnoHFzkwGtKBftdbSOmEacGoz8Tn/ZL5IuJlFZt+DFwCK0ZIf/ecwP/QpBhWbQ5cOcjWjjqCSauCtoPrgPzdp7OMnSuCbGDk0QCfW19PW7ct8OPaOs5868kexIhc5f1jpY7TriJ4I3z0s4on6v69PTkVEd/qo+eZ73dHrTojV40No+d6VDWIbIRM7eU/DRnJqSZ9R2JZg+RNWf3ljoX204aHw7HZ2aBibKgxXsImQTMVZqpyRQ+OinTXO8acfDRRw3gOCoiN4V+m0h9CthUkfjiE1ai5M5/y/Mk9SkpEqSIKKRVl3NV5rDQ== root@mhxy162.cn
[root@mhxy163 .ssh]# cat known_hosts
192.168.137.163 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOyOeMy5W+53bBgrK+yoiL6zOBj3WxBFEiNipdeiVGUMJ5BIpaLOob7Vs1T7eudLz+R9d3an+EtaLBKSPRrw8aU=
[root@mhxy163 .ssh]#
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27039319/viewspace-2104460/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27039319/viewspace-2104460/