惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - foward.molly.宝儿

POI 生成excel(大数据量) SXSSF jenkins和sonar的几个问题 Test class should have exactly one public constructor解决办法 ubuntu安装和查看已安装 rails mysql2问题 axis2依赖的其他jar, 版本不是最新的 mysql: 启动和停止服务 mysql: 安装后的目录结构 msyql: mysql rpm安装手记 - foward.molly.宝儿 velocity: velocty转义html xml等 testng: testng使用小结 IE, firefox竖向 横向滚动条处理 ruby: rdoc生成文档的好工具 spring: 一些基本配置--也许只有自己能够读懂 - foward.molly.宝儿 - 博客园 spring: web学习笔记1--异常处理:No adapter for handler - foward.molly.宝儿 maven: maven创建工程,web工程等-普通java app, web app maven: maven编译时指定maven库,即指定profile php: eclipse 编辑 php ruby: 使用netbeans debug ruby
ssh免密码登录, 发送命令到多个Linux
foward.molly.宝儿 · 2010-07-15 · via 博客园 - foward.molly.宝儿

使用SSH命令,可以实现将命令发送到指定的服务器来执行命令,这样就可以实现在一台机器向多台机器发送命令,而无需登录多个Linux,减少操作的时间成本

ssh 无密码登录要使用公钥与私钥。linux下可以用用ssh-keygen生成公钥/私钥对。

先实现免登,然后就可以实现免登命令发送

有linux机器 A,B。现想A通过ssh免密码登录到B。

1.在A机下生成公钥/私钥对。

[chenlb@A ~]$ ssh-keygen -t rsa -''

-P表示密码,-P '' 就表示空密码,也可以不用-P参数,这样就要三车回车,用-P就一次回车。
它在/home /chenlb下生成.ssh目录,.ssh下有id_rsa和id_rsa.pub。

2.把A机下的id_rsa.pub复制到B机下,在B机的.ssh/authorized_keys文件里,我用scp复制。

[chenlb@A ~]$ scp .ssh/id_rsa.pub chenlb@192.168.1.181:/home/chenlb/id_rsa.pub 
chenlb@
192.168.1.181's password:
id_rsa.pub                                    100%  223     0.2KB/s   00:00

由于还没有免密码登录的,所以要输入密码。

3.B机把从A机复制的id_rsa.pub添加到.ssh/authorzied_keys文件里。

[chenlb@B ~]$ cat id_rsa.pub >> .ssh/authorized_keys
[chenlb@B 
~]$ chmod 600 .ssh/authorized_keys

authorized_keys的权限要是600

4.A 机登录B机。

[chenlb@A ~]$ ssh 192.168.1.181
The authenticity of host 
'192.168.1.181 (192.168.1.181)' can't be established.
RSA key fingerprint is 00:a6:a8:87:eb:c7:40:10:39:cc:a0:eb:50:d9:6a:5b.
Are you sure you want to 
continue connecting (yes/no)? yes
Warning: Permanently added 
'192.168.1.181' (RSA) to the list of known hosts.
Last login: Thu Jul  
3 09:53:18 2008 from chenlb
[chenlb@B 
~]$

第一次登录是时要你输入yes。

现在A机可以无密码登录B机了。

小结:登录的机子可有私钥,被登录的机子要有登录机子的公钥。这个公钥/私钥对一般在私钥宿主机产生。上面是用rsa算法的公钥/私钥对,当然也可以用dsa(对应的文件是 id_dsa,id_dsa.pub)

想让A,B机无密码互登录,那B机以上面同样的方式配置即可。

原文出处:http://chenlb.javaeye.com/blog/211809

命令发送就简单了

ssh 192.168.1.181 'command'

这样既可实现向181的linux发送命令,当然,前提是cmmand在181下面有该命令