ssh无密登录_集群分发脚本xsync
1、ssh免密登录
ssh ip地址
[root@192 ~]# ssh 192.168.1.102
root@192.168.1.102's password:
Last login: Mon Feb 18 20:40:28 2019 from 192.168.1.101
免密登录配置
生成公钥和私钥
[root@192 ~]# 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:
d4:95:6c:a8:21:9b:27:62:79:43:76:e8:4b:32:6c:fe root@192.168.1.101
The key's randomart image is:
+--[ RSA 2048]----+
| . o.. |
| = o...+ |
| . = =.o.. |
| O O.o |
| + * =S |
| . . |
| . |
| E |
| |
+-----------------+
[root@192 ~]# ls /root/.ssh/
id_rsa id_rsa.pub
将公钥拷贝到要免密登录的目标机器上
.ssh文件夹下(~/.ssh)的文件功能解释
(1)known_hosts :记录ssh访问过计算机的公钥(public key)
(2)id_rsa :生成的私钥
(3)id_rsa.pub :生成的公钥
(4)authorized_keys :存放授权过得无密登录服务器公钥
[root@192 ~]# hostname
192.168.1.101
[root@192 ~]# ssh-copy-id 192.168.1.102
The authenticity of host '192.168.1.102 (192.168.1.102)' can't be established.
RSA key fingerprint is 56:57:4c:81:94:e0:47:fe:1e:aa:8c:9c:2a:87:a6:dc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.102' (RSA) to the list of known hosts.
root@192.168.1.102's password:
Now try logging into the machine, with "ssh '192.168.1.102'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@192 ~]# ls /root/.ssh/
id_rsa id_rsa.pub known_hosts
[root@192 ~]# ssh 192.168.1.102
Last login: Mon Feb 18 22:50:53 2019 from 192.168.1.101
[root@192 ~]# ls /root/.ssh/
authorized_keys
2、集群分发脚本xsync
服务器与服务器数据拷贝
rsync和scp区别:用rsync做文件的复制要比scp的速度快,rsync只对差异文件做更新。scp是把所有文件都复制过去。
scp
[root@192 ~]# scp -r /tmp/1.txt root@192.168.1.102:/tmp/
1.txt
rsync
选项 功能
-r 递归
-v 显示复制过程
-l 拷贝符号连接
[root@192 ~]# rsync -rvl /tmp/2.txt root@192.168.1.102:/tmp/
sending incremental file list
2.txt
sent 84 bytes received 31 bytes 76.67 bytes/sec
total size is 13 speedup is 0.11
集群分发脚本xsync
[root@192 ~]# mkdir bin
[root@192 ~]# cd bin/
[root@192 bin]# touch xsync
[root@192 bin]# vim xsync
[root@192 bin]# chmod 777 xsync
#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
pcount=$#
if((pcount==0)); then
echo no args;
exit;
fi
#2 获取文件名称
p1=$1
fname=`basename $p1`
echo fname=$fname
#3 获取上级目录到绝对路径
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir
#4 获取当前用户名称
user=`whoami`
#5 循环
for((host=102; host<104; host++)); do
echo --------------------- 192.168.1.$host ----------------
rsync -rvl $pdir/$fname $user@192.168.1.$host:$pdir
#echo ------"rsync -rvl $pdir/$fname $user@192.168.1.$host:$pdir complete"------------
done
xsync调用
[root@192 bin]# xsync /tmp/1.txt /tmp/
fname=1.txt
pdir=/tmp
--------------------- 192.168.1.102 ----------------
sending incremental file list
1.txt
sent 516 bytes received 31 bytes 364.67 bytes/sec
total size is 445 speedup is 0.81
--------------------- 192.168.1.103 ----------------
The authenticity of host '192.168.1.103 (192.168.1.103)' can't be established.
RSA key fingerprint is 56:57:4c:81:94:e0:47:fe:1e:aa:8c:9c:2a:87:a6:dc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.103' (RSA) to the list of known hosts.
root@192.168.1.103's password:
sending incremental file list
1.txt
sent 71 bytes received 37 bytes 5.84 bytes/sec
total size is 445 speedup is 4.12
ssh无密登录_集群分发脚本xsync的更多相关文章
- 配置docker容器上ssh无密登录
配置docker容器上ssh无密登录 1.修改所有容器中root账户密码 ssh到远程主机时,首次需要密码访问,因此需要修改root账号密码. 密码必须要8位以上字母数字混合. $>passwd ...
- ssh无密登录
ssh登录一般两种方式: 1.密码登录 2.密钥验证无需密码 使用方式:1.生成密钥 2.将公钥追加到authorized_keys中,需要注意的是执行权限需为600,这里因而第一次添加使用的是> ...
- ssh 免密登录
一,单机秘密登录 进入/etc/ssh 文件夹 编辑sshd_config 文件(sshd_config是ssh 服务端文件,ssh_config是客户端文件) sudo vi sshd_config ...
- CentOS 7 SSH 免密登录的方法
先决条件 3 台 CentOS 7 HOSTNAME IP ROLE server1 10.8.26.197 Master server2 10.8.26.196 Slave1 server3 10. ...
- hadoop(六)rsync远程同步|xsync集群分发(完全分布式准备三)|8
前置环境准备:centos7克隆ip|机器名|映射关系|别名配置(hadoop完全分布式准备一)scp命令copy文件和配置(hadoop完全分布式准备二) rsync远程同步工具 优点 rsync主 ...
- hadoop(八)集群namenode启动ssh免密登录(完全分布式五)|10
前置章节:hadoop集群配置同步(hadoop完全分布式四)|10 启动namenode之前: 1. 先查看有无节点启动,执行jps查看,有的话停掉 [shaozhiqi@hadoop102 ~]$ ...
- 配置ssh免密登录遇到的问题——使用VMware多虚拟机搭建Hadoop集群
搭建环境: 虚拟机 VMware12Pro 操作系统 centos6.8 hadoop 1.2.1 1.导入镜像文件,添加java环境 1.查看当前系统中安装的java,ls ...
- Hadoop伪分布式集群实现SSH免密登录
在启动Hadoop时候报了这样一个错误: Starting namenodes on [hadoop] hadoop: (Permission denied (publickey,gssapi-key ...
- 多台计算机之间的ssh无密钥登录
在很多分布式系统中,我们最常遇到的一个问题是,需要在服务器集群上保证多台机器之间的SSH无密钥登录.以Hadoop为例,为了方便,我们需要在master和slaves之间配置密钥登录,这样我们启动Ha ...
随机推荐
- 使用Xshell链接阿里云服务
1.下载Xshell,进入xshell官网 https://xshell.en.softonic.com/,选择免费版本进行下载,在该页面https://www.netsarang.com/zh/fr ...
- Ubuntu安装Redis及使用
NoSQL简介NoSQL,全名为Not Only SQL,指的是非关系型的数据库随着访问量的上升,网站的数据库性能出现了问题,于是nosql被设计出来 优点/缺点优点:高可扩展性分布式计算低成本架构的 ...
- 企业SOA架构案例分析
面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)进行拆分,并通过这些服务之间定义良好的接口和契约联系起来.接口是采用中立的方式进行定义的,它应该独立于实现服务的硬件平台. ...
- Qt编写自定义控件19-图片背景时钟
前言 图片背景时钟控件,是全套控件(目前共145个)中唯一的几个贴图的控件,这个背景要是不贴图,会画到猝死,必须用美工做好的图贴图作为背景,此控件以前学C#的时候写过,后面在写Qt控件的过程中把他移植 ...
- java文件上传系统
我们平时经常做的是上传文件,上传文件夹与上传文件类似,但也有一些不同之处,这次做了上传文件夹就记录下以备后用. 首先我们需要了解的是上传文件三要素: 1.表单提交方式:post (get方式提交有大小 ...
- Python3 编程第一步_关键字end
关键字end可以被用于防止输出新的一行,或者在输出的末尾添加不同的字符: a, b = 0, 1 while b < 1000: print(b, end=',') a, b = b, a+b ...
- React Native pod install报错 `Yoga (= 0.44.3.React)` required by `React/Core (0.44.3)`
使用pod安装,可能会因为Podfile的路径指向错误或者没有路径指向因为报错. 报错截图如下: 这是因为在指定的路径没有寻找到相应的组件.此时就需要修改podfile文件中的路径,由于上方提示没有 ...
- chrome下常用插件
1.xdebug helper 配合PhpStorm使用调试PHP 2.json-handle 格式化JSON返回数据 3.website ip 查看当前网站IP 4.host switch plus ...
- Unreal Engine* 4/英特尔® VTune™ Amplifier 使用指南
借助英特尔 VTune Amplifier,可以通过单一易用的分析界面获得先进的分析功能.UE4 和英特尔 VTune Amplifier 相互配合,支持调查代码并进行分析,从而在多个内核上顺畅运行. ...
- 关于Bootstrap Table使用生成冻结窗格的表格
参考资料 : <JS组件系列——Bootstrap Table 冻结列功能IE浏览器兼容性问题解决方案> <http://issues.wenzhixin.net.cn/bootst ...