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整合登陆 java Eclipse整合SSH
Eclipse开发SSH(Struts+Spring+Hibernate)入门 文档讲解+实例
ssh框架实现的login程序,非常适合初学者,欢迎下载
SSHLogin 基于MyEclipse的SSH简单框架 Struts+Spring+Hibernate 3大框架集成开发 具体实现 MySQL数据库
SSH框架Login技术的实现 支持myeclipse eclipse等开发软件的导入使用 对数据库需要更改登陆指令
一个非常简单的通过struts+hibernate+spring的集成来实现用户登录验证的例子,让大家了解一下三者是如何是整合的。
ssh simple login
ssh三大框架整合开发的一个登录实例,建数据库后可直接运行
Support for ssh login with password commit
SSHLogin实例(下载)[整理].pdf
SSH例子登陆例子查询添加删除例子各种实例
win10,Idea,Tomcat 8.5,mysql 实现的小案例,其中包含注解的使用,还有老师封装的DBUtils工具类
ssh2的一个简单登陆,上手简单,很容易懂的一个简单的实例。希望能给有需要的朋友帮助。
这是我花费几天做的实现简单登陆功能的ssh工程的搭建,希望可以给以大家帮助!!!!!
[ssh-skip-pwd]是ssh免密码工具,使用python语言实现的工具; 主要功能: 本机用户ssh免密码到一台主机; 本机用户自己免密码到多台主机; 本机其他用户为某一用户做免密码到多台主机 本地用户对远程主机中用户免密码到...
免密码登录原理教程
SSHKeysVia1Password 拼命尝试使用保存在1... 调整SSHKeysVia1Password.applescript的最后几行以适合您的SSH密钥路径和1Password项目名称。 运行方式: osascript /path/to/SSHKeysVia1Password.applescript
ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ssh shhs ssh ...
基于SSH2 架构的登录源代码。。。 采用ajax