重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1878|回复: 0
打印 上一主题 下一主题

[Oracle] ssh无法免密登录

[复制链接]
跳转到指定楼层
楼主
发表于 2022-3-23 13:22:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
系统:CentOS 7.9
ssh互信做完后发现仍然无法ssh免密登录,提示如下:
[oracle@hisdb1:/home/oracle]$ ssh hisdb1 date
Enter passphrase for key '/home/oracle/.ssh/id_rsa':

解决方案:
[root@hisdb1 .ssh]# vi /etc/ssh/sshd_config
确认以下参数被注释:
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#PermitEmptyPasswords no
确认以下未被注释:
PasswordAuthentication yes

保存后,重启sshd服务
[root@hisdb1 ~]# service sshd restart

使用ssh-keygen重新生成密匙
[oracle@hisdb1:/home/oracle]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):
/home/oracle/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:eiCXx/pZCDM49ljwkQ9NPRR7W25kz5FilY10HAEfIyk oracle@hisdb1
The key's randomart image is:
+---[RSA 2048]----+
|        .oo. ++O*|
|       +  oE .=o*|
|    . + . ..oo++ |
|     + *   ..*.o.|
|    = X S   . o o|
|   . B O .   .   |
|    . + o .      |
|       o o       |
|        o        |
+----[SHA256]-----+

说明:如上所示,该命令会在/home/oracle/.ssh/目录下生成以下两个文件
id_rsa 私钥文件
id_rsa.pub 公钥文件

将公钥复制到远程机器的authorized_keys文件中:
复制到hisdb1:
[oracle@hisdb1:/home/oracle]$ ssh-copy-id -i /home/oracle/.ssh/id_rsa.pub oracle@hisdb1
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/oracle/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
oracle@hisdb1's password:  

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'oracle@hisdb1'"
and check to make sure that only the key(s) you wanted were added.

复制到hisdb2:
[oracle@hisdb1:/home/oracle]$ ssh-copy-id -i /home/oracle/.ssh/id_rsa.pub oracle@hisdb2
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/oracle/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
oracle@hisdb2's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'oracle@hisdb2'"
and check to make sure that only the key(s) you wanted were added.

验证:
[oracle@hisdb1:/home/oracle]$ ssh hisdb1 date
Mon Mar 14 23:01:02 CST 2022
[oracle@hisdb1:/home/oracle]$ ssh hisdb2 date
Mon Mar 14 23:01:05 CST 2022
[oracle@hisdb1:/home/oracle]$ ssh hisdb1-priv date
Mon Mar 14 23:01:11 CST 2022
[oracle@hisdb1:/home/oracle]$ ssh hisdb2-priv date
Mon Mar 14 23:01:15 CST 2022

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-6-17 04:15 , Processed in 0.087952 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表