美文网首页
免密登录SSH(SSH login without passwo

免密登录SSH(SSH login without passwo

作者: 邵云涛 | 来源:发表于2018-11-21 17:25 被阅读51次

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(SSH login without passwo

    SSH login without password Your aimYou want to use Linux ...

  • Hadoop安装

    配置SSH免密登录 ssh localhost 验证免密登录是否配置成功 安装Java Java是Hadoop的先...

  • Centos/SSH免密登录

    Centos/SSH免密登录 test

  • Jenkins的Publish Over SSH功能将项目部署到

    免密登录设置 在使用Publish Over SSH之前,需要制作SSH私钥。机器间做免密登录配置。假设机器A,i...

  • 安装ES5.3

    ips: 192.168.61.141192.168.61.142192.168.61.143 ssh免密登录设置...

  • Ubuntu的ssh

    安装ssh 创建root用户 配置本机无密码ssh登录 spark0免密码ssh登录spark1 spark1免密...

  • linux ssh 免密登录设置

    免密登录设置 一般情况下ssh登录远程机器需要输入密码,可以设置免密登录 ssh-keygen -t rsa命令一...

  • -bash: ssh: command not found

    备注:在配置ssh免密要登录,忽然发现没有.ssh目录 查看ssh安装 安装ssh客户端 使用root登录 最后查...

  • ssh相关

    查看系统ssh安全登录日志 重启sshd服务 配置本地ssh免密登录使用ssh-copy-id将本地的ssh-ke...

  • ssh免密登录

    1、免密登录配置1.1、hostname修改 1.2、ssh免密 ssh node02看是否已经生效,如果不生效,...

网友评论

      本文标题:免密登录SSH(SSH login without passwo

      本文链接:https://www.haomeiwen.com/subject/ooicqqtx.html