配置Linux两节点SSH密钥信任

本文介绍如何在Oracle RAC环境中配置Oracle用户SSH密钥,实现两节点间的无密码登录,并验证配置的有效性。

首先感谢兄弟“瑞瑞”提供资料

1. 生成两节点Oracle用户SSH密钥

Racnode1

[root@racnode1 ~]#su - oracle--------------------->【无.ssh目录】
[oracle@racnode1 ~]$ll -a
total 32K
drwxr
-xr-x 3 oracle oinstall 4.0K Jun 13 15:08 .kde
-rw-r--r-- 1 oracle oinstall 120 Jun 13 15:08 .gtkrc
-rw-r--r-- 1 oracle oinstall 124 Jun 13 15:08 .bashrc
-rw-r--r-- 1 oracle oinstall 191 Jun 13 15:08 .bash_profile
-rw-r--r-- 1 oracle oinstall 24 Jun 13 15:08 .bash_logout
drwxr
-xr-x 3 root root 4.0K Jun 13 15:08 ..
drwx
------ 3 oracle oinstall 4.0K Jun 13 15:08 .
[oracle
@racnode1 ~]$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:
8a:
11:ad:48:03:3b:94:b4:bb:a9:fb:b4:df:e1:18:87 oracle@racnode1
[oracle
@racnode1 ~]$ssh-keygen -t dsa--------------------->【一路回车】
Generating public
/private dsa key pair.
Enter file
in which to save the key (/home/oracle/.ssh/id_dsa):
Enter passphrase (empty
for no passphrase):
Enter same passphrase again:
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:
7d:9e:de:
16:85:71:36:09:d3:9e:03:d2:1e:fd:d6:1a oracle@racnode1
[oracle
@racnode1 ~]$cat .ssh/*.pub > .ssh/authorized_keys
[oracle
@racnode1 ~]$ll -a--------------------->【生成.ssh目录,密码钥也已生成】
total 20K
-rw-r--r-- 1 oracle oinstall 225 Jun 13 15:30 id_rsa.pub
-rw------- 1 oracle oinstall 883 Jun 13 15:30 id_rsa
-rw-r--r-- 1 oracle oinstall 605 Jun 13 15:30 id_dsa.pub
-rw------- 1 oracle oinstall 668 Jun 13 15:30 id_dsa
-rw-r--r-- 1 oracle oinstall 830 Jun 13 15:35 authorized_keys

Racnode2

[root@racnode2 ~]#su - oracle--------------------->【无.ssh目录】
[oracle@racnode1 ~]$ll -a
total 32K
drwxr
-xr-x 3 oracle oinstall 4.0K Jun 13 15:08 .kde
-rw-r--r-- 1 oracle oinstall 120 Jun 13 15:08 .gtkrc
-rw-r--r-- 1 oracle oinstall 124 Jun 13 15:08 .bashrc
-rw-r--r-- 1 oracle oinstall 191 Jun 13 15:08 .bash_profile
-rw-r--r-- 1 oracle oinstall 24 Jun 13 15:08 .bash_logout
drwxr
-xr-x 3 root root 4.0K Jun 13 15:08 ..
drwx
------ 3 oracle oinstall 4.0K Jun 13 15:08 .
[oracle
@racnode2 ~]$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:
8a:
11:ad:48:03:3b:94:b4:bb:a9:fb:b4:df:e1:18:87 oracle@racnode1
[oracle
@racnode2 ~]$ssh-keygen -t dsa--------------------->【一路回车】
Generating public
/private dsa key pair.
Enter file
in which to save the key (/home/oracle/.ssh/id_dsa):
Enter passphrase (empty
for no passphrase):
Enter same passphrase again:
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:
7d:9e:de:
16:85:71:36:09:d3:9e:03:d2:1e:fd:d6:1a oracle@racnode1
[oracle
@racnode2 ~]$cat .ssh/*.pub > .ssh/authorized_keys
[oracle
@racnode2 ~]$ll .ssh/--------------------->【生成.ssh目录,密码钥也已生成】
total 20K
-rw-r--r-- 1 oracle oinstall 225 Jun 13 15:34 id_rsa.pub
-rw------- 1 oracle oinstall 883 Jun 13 15:34 id_rsa
-rw-r--r-- 1 oracle oinstall 605 Jun 13 15:34 id_dsa.pub
-rw------- 1 oracle oinstall 672 Jun 13 15:34 id_dsa
-rw-r--r-- 1 oracle oinstall 830 Jun 13 15:36 authorized_keys

2. 配置两节点Oracle用户SSH无密码登陆的信任关系

Racnode1

[oracle@racnode1 ~]$scp .ssh/authorized_keys oracle@10.10.10.102:/home/oracle/.ssh/keys_dbs
The authenticity of host '
10.10.10.102 (10.10.10.102)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added '
10.10.10.102' (RSA) to the list of known hosts.
oracle
@10.10.10.102's password:RacNode2节点Oracle用户的密码
authorized_keys 100%  830     0.8KB/s   00:00

Racnode2

[oracle@racnode2 ~]$cat .ssh/keys_dbs >> .ssh/authorized_keys
[oracle
@racnode2 ~]$scp .ssh/authorized_keys oracle@10.10.10.101:/home/oracle/.ssh/
The authenticity of host '
10.10.10.101 (10.10.10.101)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added '
10.10.10.101' (RSA) to the list of known hosts.
oracle
@10.10.10.101's password: RacNode1节点Oracle用户的密码
authorized_keys
100% 830 0.8KB/s 00:00

3. 配置两节点Oracle用户信任关系的测试

Racnode1

[oracle@racnode1 ~]$ssh racnode1
The authenticity of host 'racnode1 (
10.10.10.101)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Last login: Mon Jun
13 15:44:03 2011 from racnode1
[oracle
@racnode1 ~]$exit
logout
Connection to racnode1 closed.
[oracle
@racnode1 ~]$ssh racnode2
The authenticity of host 'racnode2 (
10.10.10.102)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Last login: Mon Jun
13 15:44:03 2011 from racnode1
[oracle
@racnode2 ~]$exit
logout
Connection to racnode1 closed.
[oracle
@racnode1 ~/.ssh]$ssh racnode1-priv
The authenticity of host 'racnode1
-priv (192.168.0.101)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added 'racnode1
-priv,192.168.0.101' (RSA) to the list of known hosts.
Last login: Mon Jun
13 15:46:07 2011 from racnode1
[oracle
@racnode1 ~]$exit
logout
Connection to racnode1
-priv closed.
[oracle
@racnode1 ~/.ssh]$ssh racnode2-priv
The authenticity of host 'racnode2
-priv (192.168.0.102)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added 'racnode2
-priv,192.168.0.102' (RSA) to the list of known hosts.
Last login: Mon Jun
13 15:46:59 2011 from racnode1
[oracle
@racnode2 ~]$exit
logout
Connection to racnode2
-priv closed.

Racnode2

[oracle@racnode2 ~]$ssh racnode1
The authenticity of host 'racnode1 (
10.10.10.101)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added 'racnode1' (RSA) to the list of known hosts.
Last login: Mon Jun
13 15:49:14 2011 from racnode1-priv
[oracle
@racnode1 ~]$exit
logout
Connection to racnode1 closed.
[oracle
@racnode2 ~]$ssh racnode2
The authenticity of host 'racnode2 (
10.10.10.102)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added 'racnode2,
10.10.10.102' (RSA) to the list of known hosts.
Last login: Mon Jun
13 15:49:28 2011 from racnode1-priv
[oracle
@racnode2 ~]$exit
logout
Connection to racnode2 closed.
[oracle
@racnode2 ~]$ssh racnode1-priv
The authenticity of host 'racnode1
-priv (192.168.0.101)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added 'racnode1
-priv,192.168.0.101' (RSA) to the list of known hosts.
Last login: Mon Jun
13 15:49:56 2011 from racnode2
[oracle
@racnode1 ~]$exit
logout
Connection to racnode1
-priv closed.
[oracle
@racnode2 ~]$ssh racnode2-priv
The authenticity of host 'racnode2
-priv (192.168.0.102)' can't be established.
RSA key fingerprint is 3c:
84:f4:d9:d8:88:2d:9c:99:47:6a:21:1c:93:95:8d.
Are you sure you want to
continue connecting (yes/no)? yes
Warning: Permanently added 'racnode2
-priv,192.168.0.102' (RSA) to the list of known hosts.
Last login: Mon Jun
13 15:50:16 2011 from racnode2
[oracle
@racnode2 ~]$exit
logout
Connection to racnode2
-priv closed.



### Jenkins配置Linux分支节点使用SSH连接的方法 #### 准备工作 为了使Jenkins能够通过SSH管理远程Linux机器作为其分支节点,需先确认目标Linux主机已安装并运行了SSH服务。通常情况下,默认的OpenSSH服务器已经满足需求。 #### 安装必要的软件包 确保在Linux客户端上安装Git工具以便于后续操作[^1]: ```bash yum install git ``` 对于Docker环境中的Jenkins实例,则按照如下指令启动带有适当权限映射的容器[^2]: ```bash docker run -u root -p 8080:8080 -p 50000:50000 \ -v jenkins-data:/var/jenkins_home \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /home/idea:/home/idea jenkinsci/blueocean ``` #### 配置SSH密钥认证 创建无密码登录机制来简化自动化流程。这一步骤涉及生成一对公私钥,并将公钥复制到远端Linux系统的`~/.ssh/authorized_keys`文件内。 ##### 在本地(即Jenkins Master)执行以下命令: ```bash ssh-keygen -t rsa -C "your_email@example.com" cat ~/.ssh/id_rsa.pub | ssh user@remote_host 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' ``` #### 添加新节点至Jenkins 进入Jenkins Web界面完成新增Node的操作,在此过程中指定采用SSH方式进行通信,并提供相应的Host名/IP地址以及凭证信息。 - **名称**: 自定义描述性的名字给这个新的agent。 - **永久代理(Permanent Agent)**: 勾选此项表示该Agent一直在线等待任务分配。 - **Remote Root Directory**: 设置远程根目录用于存放构建产物等资源。 - **Labels**: 可以为不同的项目打标签方便调度策略制定。 - **Launch method and environment configuration options**: - Launch agent by connecting it to the master (via SSH): 选择这种方式建立链接; - Hostname or IP address of remote machine: 输入要连入的目标机IP或域名; - Credentials: 利用之前准备好的SSH key对进行身份验证; #### 测试连接有效性 保存设置之后点击“Test Configuration”,如果一切正常应该可以看到成功的提示消息。此时意味着Master可以顺利地经由SSH访问Slave节点上的shell终端了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值