首页 运维 网络学院 查看内容

一个人管理上百台甚至上千台Linux服务器

2011-2-24 11:12 597 0

摘要:   第一步  在你控制机器上(你的机器,Linux)上运行如下命令  [[email protected]]~# ssh-keygen -t rsa  Generating public/pr...
关键词: linuxidc root 服务器 Success www pssh 就是 com ssh passphrase

  第一步  在你控制机器上(你的机器,Linux)上运行如下命令  [[email protected]]~# ssh-keygen -t rsa  Generating public/private rsa key pair.  Enter file in which to save the key (/root/.ssh/id_rsa):  Enter passphrase (empty for no passphrase):  Enter same passphrase again:  Your identification has been saved in /root/.ssh/id_rsa.  Your public key has been saved in /root/.ssh/id_rsa.pub.  The key fingerprint is:  7d:2a:f7:4e:87:40:ef:dd:ae:29:45:dd:2f:70:1b:ce [email protected]  在~/.ssh/目录下生成id_rsa, id_rsa.pub  将id_rsa.pub拷贝至远程主机~/.ssh目录下,并改名为authorized_keys  OK; 现在可以用ssh远程登录主机了。  补充:  ssh-keygen 时会问Enter passphrase (empty for no passphrase):  此处直接enter 跳过,下次才不会询问password  如果输入密码,下次连接远程主机时会询问私人密码(非root口令)  这一步的效果就是,访问服务器的时候不需要输入密码,方便以后就算服务器改密码也没事。  第二步  去Linux公社1号服务器下载一个叫做pssh的软件(python写的哦)  下载地址:  FTP地址:ftp://www.linuxidc.com  用户名:www.linuxidc.com  密码:www.muu.cc  在 2011年LinuxIDC.com\2月\一个人管理上百台甚至上千台Linux服务器  下载方法见 http://www.linuxidc.net/thread-1187-1-1.html  然后安装就不说了,接着修改下环境变量  [[email protected]]~/.ssh# vi /etc/profile  内容如下:  export PSSH_HOSTS="/root/servers.txt"  export PSSH_USER="root"  export PSSH_PAR="32"  export PSSH_OUTDIR="/tmp"  export PSSH_VERBOSE="0"  export PSSH_OPTIONS="UserKnownHostsFile /root/.ssh/known_hosts"  简单介绍下,第1行就是记录要控制的服务器的IP。  然后执行如下命令让环境变量生效  [[email protected]]~/.ssh# source /etc/profile  然后在/root目录下新建一个文件,把要管理的服务器IP都写在里面。  [[email protected]]~#cat servers.txt  192.168.100.240  65.111.169.35  然后测试下能不能连的上服务器  [[email protected]]~# pssh uptime  Success on 192.168.100.240:22  Success on 65.111.169.35:22  如果是success就表示成功,error当然就是失败了。  第三步  OK,经过前面的配置,激动人心在时刻来了,执行如下命令:  [[email protected]]~# pssh -h /root/servers.txt -l root -o /tmp/foo uptime  Success on 192.168.100.240:22  Success on 65.111.169.35:22  简单介绍下 -h 就是服务器IP的文件 -l 就是用户名 -o 就是把uptime执行的结果返回到/tmp/foo目录下。  接下来,我们试下关闭服务器的 sendmail  [[email protected]]~# pssh service sendmail stop  Success on 192.168.100.240:22  Success on 65.111.169.35:22  OK,提示成功,去服务器看下,没问题,搞定了。  第四步  给服务器同时上传一样的文件,简单做到  [[email protected]]/var# pscp -h /root/servers.txt -l root /var/haha.txt /var/haha.txt  Success on 192.168.100.240:22  Success on 65.111.169.35:22  说下,就是把本机的/var/haha.txt 传到服务器的/var目录。
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部