《Linux就该这么学》是由全国多名红帽架构师(RHCA)基于最新Linux系统共同编写的高质量Linux技术自学教程,极其适合用于Linux技术入门教程或讲课辅助教材。
分类: LINUX
2016-04-06 11:26:05
导读 | 作为系统管理员,你计划在 Linux 上使用 OpenSSH,完成日常工作的自动化,比如文件传输、备份数据库转储文件到另一台服务器等。为实现该目标,你需要从主机 A 能自动登录到主机 B。自动登录也就是说,要在 shell 脚本中使用ssh,而无需要输入任何密码。 |
[root@node1 ~]# ssh root@192.168.0.10 The authenticity of host '192.168.0.10 (192.168.0.10)' can't be established. RSA key fingerprint is 6d:8f:63:9b:3b:63:e1:72:b3:06:a4:e4:f4:37:21:42. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.10' (RSA) to the list of known hosts. root@192.168.0.10's password: Last login: Thu Dec 10 22:04:55 2015 from 192.168.0.1 [root@node2 ~]#
[root@node1 ~]# 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: b4:51:7e:1e:52:61:cd:fb:b2:98:4b:ad:a1:8b:31:6d root@node1.ehowstuff.local The key's randomart image is: +--[ RSA 2048]----+ | . ++ | | o o o | | o o o . | | . o + .. | | S . . | | . .. .| | o E oo.o | | = ooo. | | . o.o. | +-----------------+
[root@node1 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.0.10 root@192.168.0.10's password: Now try logging into the machine, with "ssh '192.168.0.10'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
[root@node1 ~]# ssh root@192.168.0.10 Last login: Sun Dec 13 14:03:20 2015 from
本文转载自:
免费提供最新Linux技术教程书籍,为开源技术爱好者努力做得更多更好: