【转载】SSH login without password 免密登陆
Your aim
You want to use Linux and OpenSSH to automate your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call ssh from a within a shell script.
How to do it
First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
b@B's password:
Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:
From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
- Put the public key in .ssh/authorized_keys2
- Change the permissions of .ssh to 700
- Change the permissions of .ssh/authorized_keys2 to 640
【转载】SSH login without password 免密登陆的更多相关文章
- macos ssh host配置及免密登陆
windows下面有xshell 这样的可视化ssh管理工具 macos 下面使用终端做下简单配置,也非常方便,具体过程如下 生成秘钥 cd ~/.sshssh-keygen -t rsa 生成了私钥 ...
- Git for Windows之使用SSH协议开通公钥免密登陆功能
1.删除Https的通信方式,建立SSH的通信方式 (1).查看当前的通信方式 当前是使用Https的方式与远程仓库进行通信 (2).删除HTTPS的通信方式 ok,HTTPS通信方式已删除 (3). ...
- Hadoop用户配置免密登陆
Hadoop用户配置免密登陆, 参考其他免密配置方法自己总结的更简洁的步骤. 要实现A免密登陆B,需要把A生成的公钥放到B的对应目录下, 要实现ABC之间免密登陆,把3者的公钥汇总到一个文件中, 然后 ...
- linux 下的ssh免密登陆设置
一,原理 说明: A为linux服务器a B为linux服务器b 每台linux都有ssh的服务端和客户端,linux下的ssh命令就是一个客户端 我们常用ssh协议来进行登陆或者是文件的拷贝,都需要 ...
- 阿里云ssh免密登陆突然无效
[root@node03 ~]# ssh-copy-id node02 root@node02's password: sh: .ssh/authorized_keys: Permission den ...
- SSH实现免密登陆
SSH实现免密登陆配置 ssh实现免密码登录的配置过程,主要分为以下几个步骤: serverA生成密钥,包括私钥和公钥 serverA将公钥传到serverB上 serverA上配置serverB登陆 ...
- SSH免密登陆原理及实现
声明:作者原创,转载注明出处. 作者:帅气陈吃苹果 一.SSH简介 SSH(Secure Shell)是一种通信加密协议,加密算法包括:RSA.DSA等. RSA:非对称加密算法,其安全性基于极其困难 ...
- expect 批量自动部署ssh 免密登陆
[root@node2 ssh]# cat auto_ssh.sh #!/usr/bin/expect -f ########################################## #通 ...
- [提供可行性脚本] RHEL/CentOS 7 多节点SSH免密登陆
实验说明: 在自动化部署时,会经常SSH别的机器去操作,然而每次的密码认证却很令人烦躁,尤其是很长的密码,因此SSH免密登陆就显得必不可少: 在机器数目很多的时候,使用更过的往往是Ansible分发并 ...
随机推荐
- layui table合计但是未计算的解决
在项目里table开启合计功能,但是并未进行数据计算,后来发现是field写错了的问题,上代码 for(var i = 0; i < that.checkboxAll.data.length; ...
- 三大视频网站Url的处理保存(视频和图片二选一操作)
前台Js // 视频处理 var textVideoLink=$("input[name='textVideoLink']").val(); // 去除所有有的引号和空格 var ...
- git安装以及webstorm配置git
下载及安装请移步 https://www.cnblogs.com/specter45/p/github.html 用webstorm上传代码时,首先要先下载git,网址一搜就可以搜到,然后开始配置 ...
- C++ 编译器
C++编译器 当我们定义了一个类的时候, C++编译器在默认的情况下会为我们添加默认的构造方法, 拷贝构造方法, 析构函数和=运算符 在第一次创建对象的语句中如: MyString myString ...
- nyoj 47——过河问题——————【贪心】
过河问题 时间限制:1000 ms | 内存限制:65535 KB 难度:5 描述 在漆黑的夜里,N位旅行者来到了一座狭窄而且没有护栏的桥边.如果不借助手电筒的话,大家是无论如何也不敢过桥去的 ...
- Poj 3667——hotel——————【线段树区间合并】
Hotel Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 13124 Accepted: 5664 Descriptio ...
- [转]MVC系列——MVC源码学习:打造自己的MVC框架(一:核心原理)
本文转自:http://www.cnblogs.com/landeanfen/p/5989092.html 阅读目录 一.MVC原理解析 1.MVC原理 二.HttpHandler 1.HttpHan ...
- 上传文件插件-bootstrap-fileinput
1. js文件: <link href="/bootstrap/css/fileinput.css" media="all" rel="styl ...
- 今天研究Unity Ioc 框架
今天研究Unity Ioc 框架,被自己坑了两个多小时. 运行就报错,反反复复检查了很多次,配置文件,代码都没有问题,也从新写了好几遍. 最后仔细看报错消息才知道,config文件没有生成到目录……… ...
- mysql三-3:完整性约束
一.完整性约束介绍 约束条件与数据类型的宽度一样,都是可选参数 作用:用于保证数据的完整性和一致性主要分为: PRIMARY KEY (PK) 标识该字段为该表的主键,可以唯一的标识记录 FOREIG ...