环境: CentOS 5.7
1. 配置好免密码登录的SSH
场景: 主机A, B, A访问B
首先在主机A执行
[oracle@A ~]$ ssh-keygen -t rsa -P ”
[oracle@A ~]$ scp .ssh/id_rsa.pub oracle@B:/home/oracle
主机B执行:
[oracle@B ~]$ cat /home/oracle/id_rsa.pub > ~/.ssh/authorized_keys
[oracle@B ~]$ chmod 600 ~/.ssh/authorized_keys
[oracle@B ~]$ chmod 700 ~/.ssh
2. vi test_ssh.sh
脚本如下
#!/bin/sh
cmd=”
cd /home/oracle
. ~/.bash_profile
ls
python load_zhixin.py “$1″
”
echo $cmd
ssh oracle@xx.xx.xx.xx “$cmd”
3. 执行如下 ./test_ssh.sh 20140917