一、环境配置
1、服务端:CentOS release 5.8 IP:192.168.1.111
2、客服端:CentOS release 5.8 IP:192.168.1.110
二、配置SSH无密码登录需要3步:
1、生成公钥和私钥
2、导入公钥到认证文件,更改权限
3. 客户端也要进行相应的配置,进行两台服务器的双向连接,再与不进行演示了
1、服务端:CentOS release 5.8 IP:192.168.1.111
2、客服端:CentOS release 5.8 IP:192.168.1.110
二、配置SSH无密码登录需要3步:
1、生成公钥和私钥
2、导入公钥到认证文件,更改权限
3、测试
三、配置公钥与私钥
1.服务端生成公钥与私钥
[oracle@asm ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/oracle/.ssh/id_rsa): #回车(代表无需密码登陆) Created directory '/home/oracle/.ssh'. Enter passphrase (empty for no passphrase): #回车 Enter same passphrase again: #回车 Your identification has been saved in /home/oracle/.ssh/id_rsa.#代表私钥 Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.#代表公钥 The key fingerprint is: 59:0d:c0:b2:89:98:f0:bc:f7:6d:8f:21:69:c3:57:84 oracle@asm
[oracle@asm ~]$ cd /home/oracle/.ssh/ [oracle@asm .ssh]$ ls id_rsa id_rsa.pub known_hosts
3. 客户端也要进行相应的配置,进行两台服务器的双向连接,再与不进行演示了
4.把服务端的公钥拷贝到客户端的~/.ssh/目录下,并命名为authorized_keys
[oracle@asm .ssh]$ scp -r id_rsa.pub oracle@192.168.1.110://home/oracle/.ssh/authorized_keys oracle@192.168.1.110's password: id_rsa.pub5.把客户端的公钥拷贝到服务端的~/.ssh/目录下,并命名为authorized_keys,进行两台服务器的双向连接,再与不进行演示了
6.分别修改服务端和客户端相应目录的权限
[oracle@asm ~]#chmod 700 ~/.ssh [oracle@asm ~]#chmod 600 ~/.ssh/authorized_keys7.分别重启服务端和客户端的ssh服务,root角色
[root@asm ~]# service sshd restart Stopping sshd: [ OK ] Starting sshd: [ OK ]8.测试两台机器之间传输文件不需要密码
服务端到客户端传输文件不需要密码
[oracle@asm tmp]$ touch test.oracle [oracle@asm tmp]$ scp test.oracle oracle@192.168.1.110://tmp test.oracle 100% 0 0.0KB/s 00:00客户湍到服务端传输文件不需要密码
[oracle@asm tmp]$ scp test.oracle oracle@192.168.1.111://tmp test.oracle 100% 0 0.0KB/s 00:00