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 ...
随机推荐
- 7.RabbitMQ--消息确认机制(confirm)
RabbitMQ--消息确认机制(confirm) Confirm模式 RabbitMQ为了解决生成者不知道消息是否真正到达broker这个问题,采用通过AMQP协议层面为我们提供了事务机制方案,但是 ...
- IDEA项目结构只剩下了pom,而代码都找不到了
大体效果就是下面这个样子的, 只剩下一个pom文件了. 解决方式: 本来想彻底排查下的,但是最后发现 直接删除.idea文件, 重新引入项目,就可以解决,可能就是编译器发神经吧 下面是排查的过程,不过 ...
- idea2018.3.2版本如何破解
IntelliJ IDEA2018破解教程(2019.1.11更新)破解方法:下载破解补丁→修改配置文件→输入激活码→激活成功 由于JetBrains封杀,大部分激活服务器已经不能使用,使用下面的比较 ...
- Leetcode题目238.除自身以外数组的乘积(中等)
题目描述: 给定长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积. 示例: ...
- Scrapy教程——搭建环境、创建项目、爬取内容、保存文件
1.创建项目 在开始爬取之前,您必须创建一个新的Scrapy项目.进入您打算存储代码的目录中,运行新建命令. 例如,我需要在D:\00Coding\Python\scrapy目录下存放该项目,打开命令 ...
- ObjectId初探
ObjectId MongoDB每个集合存储的每个文档必须有一个"_id"键,默认是个ObjectId对象. "_id"作为当前文档在集合的唯一标识. 71st ...
- docker 搭建私有云盘 Seafile
缘起 现如今各种云存储服务其实挺多的,国外有经典的DropBox.Google Drive.微软的OneDrive等,国内也有可以免费使用的各种云. 那么为什么想要搭建私有云存储呢?主要是本着“自己的 ...
- spring boot系列(六)spring boot 配置mybatis(xml简化版)
orm框架的本质是简化编程中操作数据库的编码,发展到现在基本上就剩两家了,一个是宣称可以不用写一句SQL的hibernate,一个是可以灵活调试动态sql的mybatis,两者各有特点,在企业级系统开 ...
- Junit单元测试学习
一.首先选择学习工具是IDEA 1>官网下载IDEA 1:官网地址IntelliJ IDEA,官网上对于不同的操作系统(windows,macOS,Linux)都有两个版本可供下载| 其中蓝色下 ...
- vue等单页面应用优缺点
优点 Vue 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件,核心是一个响应的数据绑定系统. 数据驱动 组件化 轻量 简洁 高效 模块友好 页面切换快 缺点 不支持低版本的浏览器 ...