现在要添加ssh的认证密钥免去每次ssh登录服务器要输入用户名和密码
<!--
@page { size: 21.59cm 27.94cm; margin: 2cm }
P { margin-bottom: 0.21cm }
-->
第一步:生成密匙对,我用的是
rsa的密钥。使用命令
"ssh-keygen -t rsa"
第二步:把生成的密钥传到你要登录的服务器的 /root/.ssh/authorized_keys
scp /root/.ssh/id_rsa.pub root@134.161.1.158:/root/.ssh/authorized_keys
这样你下次登录对方服务器就可以不需要用户名和密码
下面我们就来讲讲同时对多个服务器进行操作,比如我服务器A上有一个文件包,要传到其他的14个地市服务器
因为现在SSH不需要用户名和密码就可以这样实现
for host in host1 host2 host3 ...
do
scp <filelist> "$host:/path/to/destination"
done
for host in 134.165 134.167.4 34.1638 1364.80 1 134.4.180 3.6.131.71 10.1.200 13.72 134.16 17.34 13
436 13.1. ;
do
scp /opt/wifioss/node.tgz root@$host:/opt/wifioss/node.tgz;
done
统一升级地市采集: MY SOLUTION
第一:生成上述
rsa的密钥对,并scp到地市的/root/.ssh/authorized_keys中
第二:在/etc/hosts中添加对应各地市名陈的host与名陈对应
122.2.2.2 changde
122.3.3.3 zhuzhou
122.4.4.4 changsha
……
第三:通过循环完成对各个地市的采集补丁升级
for host in changde changsha chenzhou hengyang huaihua jishou loudi shaoyang xiangtan yiyang yongzhou yueyang zhuzhou; do ssh $host 'cd /opt/wifioss/node;tar xvf patch0928.tgz;make'; done
地市A日志:src/monet/monet_util.erl
(cd src;make)
make[1]: Entering directory `/opt/wifioss/node/src'
(cd core;make)
make[2]: Entering directory `/opt/wifioss/node/src/core'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/opt/wifioss/node/src/core'
(cd cron;make)
……
地市B日志:
src/monet/monet_util.erl
(cd src;make)
make[1]: Entering directory `/opt/wifioss/node/src'
(cd core;make)
make[2]: Entering directory `/opt/wifioss/node/src/core'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/opt/wifioss/node/src/core'
(cd cron;make)
make[2]: Entering directory `/opt/wifioss/node/src/cron'
……
……
这样就完成了对14个地市采集补丁的统一升级
分享到:
相关推荐
1. **Key Pair Generation**:SSH库提供了生成RSA、DSA、ECDSA等公钥/私钥对的功能,这是SSH认证的基础。开发者可以使用这些API来生成本地密钥对,或者解析已有的密钥文件。 2. **Authentication**:SSH-lib支持...
putty 最新版本 PuTTY (the Telnet and SSH client itself) PSCP (an SCP client, i.e. command-line secure file copy) PSFTP (an SFTP client, i.e....PuTTYgen (an RSA and DSA key generation utility).
Here are the PuTTY files themselves: PuTTY (the Telnet and SSH client itself) PSCP (an SCP client, i.e. command-line secure file copy) ...PuTTYgen (an RSA and DSA key generation utility).
- **Secure Protocols:** Discusses secure communication protocols such as SSL/TLS, SSH, and IPSec, which provide confidentiality, integrity, and authentication. - **Network Attacks:** Analyzes common ...
Backup Key Files ...................................................................................................................................... 12 Create /opt/CIS Directory (optional) ...........