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的更多相关文章

  1. 配置docker容器上ssh无密登录

    配置docker容器上ssh无密登录 1.修改所有容器中root账户密码 ssh到远程主机时,首次需要密码访问,因此需要修改root账号密码. 密码必须要8位以上字母数字混合. $>passwd ...

  2. ssh无密登录

    ssh登录一般两种方式: 1.密码登录 2.密钥验证无需密码 使用方式:1.生成密钥 2.将公钥追加到authorized_keys中,需要注意的是执行权限需为600,这里因而第一次添加使用的是> ...

  3. ssh 免密登录

    一,单机秘密登录 进入/etc/ssh 文件夹 编辑sshd_config 文件(sshd_config是ssh 服务端文件,ssh_config是客户端文件) sudo vi sshd_config ...

  4. CentOS 7 SSH 免密登录的方法

    先决条件 3 台 CentOS 7 HOSTNAME IP ROLE server1 10.8.26.197 Master server2 10.8.26.196 Slave1 server3 10. ...

  5. hadoop(六)rsync远程同步|xsync集群分发(完全分布式准备三)|8

    前置环境准备:centos7克隆ip|机器名|映射关系|别名配置(hadoop完全分布式准备一)scp命令copy文件和配置(hadoop完全分布式准备二) rsync远程同步工具 优点 rsync主 ...

  6. hadoop(八)集群namenode启动ssh免密登录(完全分布式五)|10

    前置章节:hadoop集群配置同步(hadoop完全分布式四)|10 启动namenode之前: 1. 先查看有无节点启动,执行jps查看,有的话停掉 [shaozhiqi@hadoop102 ~]$ ...

  7. 配置ssh免密登录遇到的问题——使用VMware多虚拟机搭建Hadoop集群

    搭建环境: 虚拟机 VMware12Pro      操作系统  centos6.8        hadoop 1.2.1 1.导入镜像文件,添加java环境 1.查看当前系统中安装的java,ls ...

  8. Hadoop伪分布式集群实现SSH免密登录

    在启动Hadoop时候报了这样一个错误: Starting namenodes on [hadoop] hadoop: (Permission denied (publickey,gssapi-key ...

  9. 多台计算机之间的ssh无密钥登录

    在很多分布式系统中,我们最常遇到的一个问题是,需要在服务器集群上保证多台机器之间的SSH无密钥登录.以Hadoop为例,为了方便,我们需要在master和slaves之间配置密钥登录,这样我们启动Ha ...

随机推荐

  1. 8 HashMap

    1.Map接口 public interface Map<K, V> 将键映射到值的对象,一个映射不能包含重复的键,每个键只能映射到一个值. 具体的实现:HashMap,TreeMap, ...

  2. MAC下STF安装及踩坑

    [Mac OS X]brew: command not found ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebr ...

  3. 【Spark机器学习速成宝典】推荐引擎——协同过滤

    目录 推荐模型的分类 ALS交替最小二乘算法:显式矩阵分解 Spark Python代码:显式矩阵分解 ALS交替最小二乘算法:隐式矩阵分解 Spark Python代码:隐式矩阵分解 推荐模型的分类 ...

  4. 后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件

    后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件 一.总结 一句话总结: vue中的插件的使用和js插件的使用一样的简单,只是vue插件的引入过程有些不同 ...

  5. centos7 防火墙开启 (重点)

    如果在自己服务器上想开启远端访问功能,需要开启防火墙 1.通过systemctl status firewalld查看firewalld状态,发现当前是dead状态,即防火墙未开启. 2.通过syst ...

  6. UML 2.5版本与UML分类概述

    UML 2.5版本与UML分类概述 转 http://www.umlstudy.com/uml-25-diagrams.html UML简述 UML图是设计.实现或已经存在的系统模型的部分图形表示(视 ...

  7. an extra named object property

    Grunt supports the ability to split each task configuration into several separate configurations all ...

  8. Mac配置React Native开发环境

    一直觉得学习一样东西,不动手怎么也学不会,就像学习swift,看了视频没有动手操作,记住的也就那么点,自己写出东西不是这里有问题就是那里出错. 所以,以后学习自己要多动手. 现在我的学习任务就是: 提 ...

  9. SpringBoot: 4.SpringBoot整合listener(转)

    整合方式一:通过注解扫描完成 Listener 组件的注册 1.编写listener package com.bjsxt.listener; import javax.servlet.ServletC ...

  10. svn clearup svn cleanup failed–previous operation has not finished; run cleanup if it was int错误的解决办法

    今天svn提交,出现异常:svn cleanup failed–previous operation has not finished; run cleanup if it was interrupt ...