环境:两台Solaris Server A和B, 用户UserA, UserB
需求: A服务器上有脚本Script_a,B服务器上有脚本Script_b。需要通过调用Script_a来跑Script_b, 进而运行B机上的其他程序,例如ETL Job(Workflow)
实现: SSH without a password
第一步: 在A机使用ssh-keygen产生一对钥匙文件
1. 创建.ssh目录,并赋予适当权限
%cd .ssh .ssh No such file or directory %mkdir .ssh %chmod 700 .ssh 2. 创建ssh钥匙文件对
% ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/export/home/xxxx/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /export/home/xxxx/.ssh/id_rsa. Your public key has been saved in /export/home/hier/.ssh/id_rsa.pub. The key fingerprint is: 8d:7b:9d:.......... username@servername % 3. 更改私有钥匙文件属性
%chmod 600 id_rsa第二步: 传送公共钥匙文件到B机
方法一:使用FTP传输
方法二:使用SCP传输
1. 在B机UserB目录创建.ssh目录
2, 在B机UserB目录安装该钥匙
$ cat id_dsa.pub >> .ssh/authorized_keys $ chmod 700 .ssh
第三步: 测试无密码连接是否配置陈功
从A机用户UserA目录下输入
%ssh UserB@B
(如果指定了Passphrase则出现下面提示,如果输入空Passphrase,则不提示)
Enter passphrase for key '/export/home/hiper/.ssh/id_rsa':
$(B机提示符)
第四步:在两机配置简单脚本进行测试
1. 在A机创建如下简单脚本test.sh
ssh -l UserB B "absolute path/rpctest.sh"
2. 在B机创建简单脚本rpctest.sh,可以调用ETL工作(流)
直接在A机运行test.sh,之后查看B机上是否完成了期望的工作
参考文章:
http://www.mines.edu/~gmurray/HowTo/sshNotes.html
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/18447/viewspace-178861/
,如需转载,请注明出处,否则将追究法律责任。