阿里云centos设置服务器间免密码ssh登录

服务器

SVN主机A:192.168.1.215 用户 svnuser
WEB主机B:192.168.1.149 用户 root

步骤
主机A中执行如下:

1、cd ~/.ssh

2、ssh-keygen -t rsa
然后一直按回车键,就会按照默认的选项将生成的密钥保存在.ssh/id_rsa文件中。

[[email protected] bin]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/svnuser/.ssh/id_rsa): 
Created directory '/home/svnuser/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/svnuser/.ssh/id_rsa.
Your public key has been saved in /home/svnuser/.ssh/id_rsa.pub.
The key fingerprint is:
c5:ae:e4:6b:21:df:cb:c7:bb:90:4d:ad:46:04:45:27 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|          .oE .  |
|         . . o   |
|          o .    |
|         o . .   |
|        S . o .  |
|      .o.. = .   |
|       oooo.+    |
|        oo.oo    |
|       .. oooo   |
+-----------------+

3、cp id_rsa.pub authorized_keys

这步完成后,正常情况下就可以无密码登录本机了,即ssh localhost,无需输入密码。

[[email protected] logs]$ ssh localhost
Last login: Sun Feb 14 15:19:14 2016 from localhost
[[email protected] ~]$

4、scp authorized_keys [email protected]:/root/.ssh

把刚刚产生的authorized_keys文件拷一份到主机B上。

5、chmod 700 authorized_keys

进入主机B的.ssh目录,改变authorized_keys文件的许可权限。

执行完毕以上5步骤后,一般情况会成功配置,注意用户的身份。

阿里云centos设置服务器间免密码ssh登录》有1个想法

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.