第5步:建立主机间的信任关系(sgdb1、sgdb2)

5.1 Oracle 用户下建立信任
5.11 创建 .ssh 目录
[root@sgdb1 /]# su - oracle
[oracle@sgdb1 ~]$ mkdir .ssh        创建一个 .ssh 的隐藏目录
[oracle@sgdb1 ~]$ ls -al
total 44
-rw-r--r-- 1 oracle oinstall   33 Jul 12 17:05 .bash_logout
-rw-r--r-- 1 oracle oinstall  438 Jul 12 18:03 .bash_profile
drwxr-xr-x 4 oracle oinstall 4096 Jul 1217:05 .mozilla
drwx------ 2 oracle oinstall 4096 Jul 1218:05 .ssh
-rw------- 1 oracle oinstall  657 Jul 12 18:03 .viminfo
5.12 sgdb1 生成密钥 rsa 类型
id_rsa 为私钥,自动保存到 .ssh
id_rsa.pub 为公钥,自动保存到 .ssh
[oracle@sgdb1 ~]$ ssh-keygen -t rsa      
Generating public/private rsa key pair.
Enter file in which to save the key(/home/oracle/.ssh/id_rsa):  enter
Enter passphrase (empty for nopassphrase):  enter
Enter same passphrase again:  enter
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:
64:a6:4a:77:db:33:a4:aa:6e:ca:8f:5f:2f:77:0f:40oracle@sgdb1
5.12 sgdb1 生成密钥 dsa 类型
id_dsa 为私钥,自动保存到 .ssh
id_dsa.pub 为公钥,自动保存到 .ssh
[oracle@sgdb1 ~]$ ssh-keygen -t dsa     
Generating public/private dsa key pair.
Enter file in which to save the key(/home/oracle/.ssh/id_dsa): enter                        
Enter passphrase (empty for no passphrase):enter
Enter same passphrase again: enter
Your identification has been saved in/home/oracle/.ssh/id_dsa.
Your public key has been saved in/home/oracle/.ssh/id_dsa.pub.                
The key fingerprint is:
7c:41:b5:0f:81:06:ad:30:07:4f:8b:1a:9b:94:68:14oracle@sgdb1
5.13 sgdb2 生成密钥 rsa 类型
id_rsa 为私钥,自动保存到 .ssh
id_rsa.pub 为公钥,自动保存到 .ssh
 [oracle@sgdb2 asm]# su - oracle
[oracle@sgdb2 ~]$ mkdir .ssh
[oracle@sgdb2 ~]$ ssh-keygen -t rsa      
Generating public/private rsa key pair.
Enter file in which to save the key(/home/oracle/.ssh/id_rsa):  enter             
Enter passphrase (empty for nopassphrase):  enter
Enter same passphrase again:  enter
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:
64:a6:4a:77:db:33:a4:aa:6e:ca:8f:5f:2f:77:0f:40oracle@sgdb1
5.14 sgdb2 生成密钥 dsa 类型
id_dsa 为私钥,自动保存到 .ssh
id_dsa.pub 为公钥,自动保存到 .ssh
 [oracle@sgdb2 ~]$ ssh-keygen -tdsa    
Generatingpublic/private dsa key pair.
Enter file inwhich to save the key (/home/oracle/.ssh/id_dsa): enter                        
Enter passphrase(empty for no passphrase): enter
Enter samepassphrase again: enter
Youridentification has been saved in /home/oracle/.ssh/id_dsa.
Your public keyhas been saved in /home/oracle/.ssh/id_dsa.pub.                
The keyfingerprint is:
7c:41:b5:0f:81:06:ad:30:07:4f:8b:1a:9b:94:68:14oracle@sgdb1
5.16 sgdb1 配置信任
rsa dsa 为私钥, .pub 的为公钥  
ssh 下文件 authorized_keys 是专门存储公钥信息的
rsa dsa 类型的公钥文件都放入到 authorized_keys 文件里
ssh  sgdb2 ”命令代表登陆到节点 2 下操作
把两种类型的公钥信息都放到节点 2 authorized_keys 文件里
[oracle@sgdb1 ~]$ ls .ssh
id_dsa       id_rsa             id_dsa.pub   id_rsa.pub     
[oracle@sgdb1 ~]$ cat.ssh/id_rsa.pub >>.ssh/authorized_keys
[oracle@sgdb1 ~]$ cat.ssh/id_dsa.pub >>.ssh/authorized_keys
[oracle@sgdb1 ~]$ ssh sgdb2  cat .ssh/id_rsa.pub>>.ssh/authorized_keys
oracle@sgdb2's password:
[oracle@sgdb1 ~]$ ssh sgdb2  cat .ssh/id_dsa.pub>>.ssh/authorized_keys
oracle@sgdb2's password:  oracle 的密码
5.17 sgdb2 配置信任
可以把sgdb1中的authorized_keys(密钥文件)复制到sgdb2中
[oracle@sgdb1 ~]$ scp.ssh/authorized_keys   sgdb2:~/.ssh
oracle@sgdb2's password: oracle 的密码
5.18 sgdb1 上验证信任
[oracle@sgdb1 ~]$ ssh sgdb2 date
[oracle@sgdb1 ~]$ ssh sgdb 2-privdate     // 私有 ip 地址验证
[oracle@sgdb1 ~]$ ssh sgdb 1date
[oracle@sgdb1 ~]$ ssh sgdb 1-privdate    
5.19 sgdb2 上验证信任
[oracle@sgdb2 ~]$ ssh sgdb1 date
[oracle@sgdb2~]$ ssh sgdb 1-priv date    
[oracle@sgdb2 ~]$ ssh sgdb2 date
[oracle@sgdb2~]$ ssh sgdb2-priv date    
5.2 Grid 用户下建立信任
步骤同 oracle  一样,可参考oracle用户下设置
5.21 创建 .ssh 目录
在grid用户下操作:
[root@sgdb1 /]# su– grid
[grid@sgdb1 ~]$mkdir .ssh       创建一个 .ssh 的隐藏目录
[grid@sgdb1 ~]$ ls-al
5.22 sgdb1 生成密钥 rsa 类型
id_rsa 为私钥,自动保存到 .ssh
id_rsa.pub 为公钥,自动保存到 .ssh
[grid@sgdb1 ~]$ ssh-keygen-t rsa     
Generating public/private rsa key pair.
Enter file in which to save the key(/home/oracle/.ssh/id_rsa):  enter             
Enter passphrase (empty for no passphrase):  enter
Enter same passphrase again:  enter
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:
64:a6:4a:77:db:33:a4:aa:6e:ca:8f:5f:2f:77:0f:40oracle@sgdb1
5.23 sgdb1 生成密钥 dsa 类型
id_dsa 为私钥,自动保存到 .ssh
id_dsa.pub 为公钥,自动保存到 .ssh
  [grid@sgdb1 ~]$ ssh-keygen-t dsa    
Generating public/private dsa key pair.
Enter file in which to save the key(/home/oracle/.ssh/id_dsa): enter                        
Enter passphrase (empty for no passphrase): enter
Enter same passphrase again: enter
Your identification has been saved in/home/oracle/.ssh/id_dsa.
Your public key has been saved in/home/oracle/.ssh/id_dsa.pub.                
The key fingerprint is:
7c:41:b5:0f:81:06:ad:30:07:4f:8b:1a:9b:94:68:14oracle@sgdb1
5.24 sgdb2 生成密钥 rsa 类型
id_rsa 为私钥,自动保存到 .ssh
id_rsa.pub 为公钥,自动保存到 .ssh
 [root@sgdb2 ~]# su grid
[grid@sgdb2 ~]$ mkdir .ssh
[grid@sgdb2 ~]$ ssh-keygen-t rsa     
Generating public/private rsa key pair.
Enter file in which to save the key(/home/oracle/.ssh/id_rsa):  enter             
Enter passphrase (empty for no passphrase):  enter
Enter same passphrase again:  enter
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:
64:a6:4a:77:db:33:a4:aa:6e:ca:8f:5f:2f:77:0f:40oracle@sgdb1
5.25 sgdb2 生成密钥 dsa 类型
id_dsa 为私钥,自动保存到 .ssh
id_dsa.pub 为公钥,自动保存到 .ssh
[grid@sgdb2 ~]$ ssh-keygen -t dsa    
Generating public/private dsa key pair.
Enter file in which to save the key(/home/oracle/.ssh/id_dsa): enter                        
Enter passphrase (empty for no passphrase): enter
Enter same passphrase again: enter
Your identification has been saved in/home/oracle/.ssh/id_dsa.
Your public key has been saved in/home/oracle/.ssh/id_dsa.pub.                
The key fingerprint is:
7c:41:b5:0f:81:06:ad:30:07:4f:8b:1a:9b:94:68:14oracle@sgdb1
5.26 sgdb1 配置信任
[grid@sgdb1 ~]$ ls .ssh
id_dsa       id_rsa             id_dsa.pub   id_rsa.pub      known_hosts
[grid@sgdb1 ~]$ cat.ssh/id_rsa.pub >>.ssh/authorized_keys
[grid@sgdb1 ~]$ cat.ssh/id_dsa.pub >>.ssh/authorized_keys
[grid@sgdb1 ~]$ ssh sgdb2  cat .ssh/id_rsa.pub>>.ssh/authorized_keys
grid@sgdb2's password:
[grid@sgdb1 ~]$ ssh sgdb2  cat .ssh/id_dsa.pub >>.ssh/authorized_keys
grid@sgdb2's password: grid 的密码
5.27 sgdb2 配置信任
可以把sgdb1中的authorized_keys(密钥文件)复制到sgdb2中
[grid@sgdb1 ~]$ scp.ssh/authorized_keys   sgdb2:~/.ssh
grid@sgdb2's password: grid 的密码
authorized_keys                             100% 1992     2.0KB/s  00:00 
5.28 sgdb1 上验证信任
[grid@sgdb1 ~]$ ssh sgdb2 date
[grid@sgdb1 ~]$ ssh sgdb2-priv date    
[grid@sgdb1 ~]$ ssh sgdb1 date
[grid@sgdb1 ~]$ ssh sgdb 1-priv date    
5.29 sgdb2 上验证信任
[grid@sgdb2 ~]$ ssh sgdb1 date
[grid@sgdb2~]$ ssh sgdb1-priv date    
[grid@sgdb2 ~]$ ssh sgdb2 date
[grid@sgdb2~]$ ssh sgdb2-priv date   
 

转载于:https://www.cnblogs.com/wuwanyu/p/8275603.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值