自动添加 ssh key 到远程主机的脚本,应用sshpass和ssh-copy-id
USERNAME=$
PASSWORD=$
HOST=$ if [ "$3" = "" ]; then
echo "Missing parameter 3 - host. Exit."
exit
fi if [ "$2" = "" ]; then
echo "Missing parameter 2 - password. Exit."
exit
fi if [ "$1" = "" ]; then
echo "Missing parameter 1 - username. Exit."
exit
fi if [ -f ~/.ssh/config ]; then
grep StrictHostKeyChecking ~/.ssh/config
exist=`echo $?` if [ ! "$exist" = "" ]; then
echo StrictHostKeyChecking no >> ~/.ssh/config
fi
else
echo StrictHostKeyChecking no >> ~/.ssh/config
fi sshpass -p ${PASSWORD} ssh-copy-id -i ~/.ssh/id_rsa.pub ${USERNAME}@${HOST} result=`echo $?` if [ "$result" = "" ]; then
echo "Host ${HOST} is configured successfully."
else
echo "Host ${HOST} configure failed."
fi
自动添加 ssh key 到远程主机的脚本,应用sshpass和ssh-copy-id的更多相关文章
- linux 多个ssh key 登录远程主机
登录A主机使用分配的sshkey需要指定特定的key,ssh -i ~/.ssh/xxx_id_rsa_privatekey username@host , 指定key后登录提示: Agent ...
- github 添加 SSH key
在 github 上添加 SSH key 的步骤: 1.首先需要检查你电脑是否已经有 SSH key 运行 git Bash 客户端,输入如下代码: $ cd ~/.ssh $ ls 这两个命令就是检 ...
- github入门:设置添加ssh key<转>
GitHub是个分布式的版本控制库.github通过git使用,可以方便的记录代码版本. 通过github可以学习优秀的代码,可以改进提交其他项目中的bug,借助社区力量促进软件优化完善. 国内外大量 ...
- 为github添加ssh key
用git关联github上的远程仓库前需要先为github添加ssh key 一.检查本机是否生成ssh key 本地查找.ssh文件,其中id_rsa.pub中的内容就是ssh key 二.为git ...
- permission denied (publickey)问题的解决 和 向github添加ssh key
使用ssh key这种方式进行clone ,pull github上面的项目,使用 git clone或者git pull origin master出现permission denied (publ ...
- permission denied (publickey)问题的解决和向github添加ssh key
使用ssh key这种方式进行clone ,pull github上面的项目,使用 git clone或者git pull origin master出现permission denied (publ ...
- 如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程!
如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程! 一. 生成 SSH key https://ide.c9.io/xgqfrms/ 创建一个空项目:(或使用 ...
- 电脑添加多个SSH key
创建新得ssh key ssh-keygen -t rsa -C "excem@excemple" -f ~/.ssh/id_rsa.gitlab 编辑config vim ~/. ...
- Git 生成SSH Key
背景:服务器是LINUX系统(centos7),使用GitLab管理git代码库.各个客户端通过sourcetree 工具,采用SSH获取.提交代码.使用SSH的方式需要公钥和私钥.下面介绍秘钥的生成 ...
随机推荐
- Python——print函数输出对齐问题
原创声明:本文系博主原创文章,转载及引用请注明出处. 当我们使用print函数时,若指定输出宽度,例如: >>> import math >>> print('|P ...
- Ubuntu 安装openmpi
Ubuntu14.04TLS安装openmpi参考:https://likymice.wordpress.com/2015/03/13/install-open-mpi-in-ubuntu-14-04 ...
- return new Promise的时候,不能带着.then()方法
app.js return new Promise的同时带着.then()方法会出错 return出去的这个Promise,整体状态会显示pending,虽然详细里状态显示resolve,但是没有re ...
- Qt 多线程使用moveToThread
Qt有两种多线程的方法,其中一种是继承QThread的run函数,另外一种是把一个继承于QObject的类用moveToThread函数转移到一个Thread里. Qt4.8之前都是使用继承QThre ...
- Http中的三种请求处理模式(MPM)的区别
MPM---包括基于事件/异步,线程化和预分叉 MPM(multi-processing module)多种请求处理模式,分为三种工作模式: prefork worker event prefork- ...
- .net大文件上传断点续传源码
IE的自带下载功能中没有断点续传功能,要实现断点续传功能,需要用到HTTP协议中鲜为人知的几个响应头和请求头. 一. 两个必要响应头Accept-Ranges.ETag 客户端每次提交下载请求时,服务 ...
- 【模板】OI常用模板(待补充)
//PS:最近修改日期:2017-11-07 20:41:44 首先感觉这种模板类的东西写了还是很有意义的,毕竟时不时的可以拿出来借鉴一下. 现在因为刚开始写这一类的东西,所以说还不是很详细,若有读者 ...
- 进程间通信之管道--pipe和fifo使用
匿名管道pipe 函数原型: #include <unistd.h> int pipe(int fildes[2]); 参数说明 fildes是我们传入的数组,也是一个传出参数.filde ...
- Android_(控件)使用ListView显示Android系统SD卡的文件列表_02
使用ListView显示Android SD卡中的文件列表 父类布局activity_main.xml,子类布局item_filelayout(一个文件的单独存放) 运行截图: 程序结构 <?x ...
- HDU 5884 Sort ——(K叉哈夫曼树)
这题真心比较奥义,先见这个人的博客:http://blog.csdn.net/libin66/article/details/52565484 补0的方法是使得其满足成为满K叉树,而其博客中所说的“所 ...