使用ssh-keygen打通两台主机间通道,只能单向跳转

时间:2021-12-23 18:26:02
大家好,今天遇到个奇怪的问题,我在打通两台服务器之间的通道的时候,使用ssh-keygen -t dsa生成id_dsa.pub以后,互相把对方id_dsa.pub中的内容添加到自己的authorized_keys中,可是现在A能跳到B,B跳不到A,跳转A的时候仍然提示输入密码。
不会存在操作上的错误,我重复做了好几次了。不知道从何下手,如何解决这个问题,还请大家多多帮忙!谢谢!
下面附上跳转时的命令
[wanghai01@tc-crm-rd03.tc ~]$ ssh wanghai01@tc-crm-rd02.tc
[wanghai01@tc-crm-rd02.tc ~]$ 
[wanghai01@tc-crm-rd02.tc ~]$ ssh wanghai01@tc-crm-rd03.tc
wanghai01@tc-crm-rd03.tc's password: 

11 个解决方案

#1


ssh-keygen -t  rsa 然后可以用ssh-copy-id 这个脚本辅助设置一下
ssh-copy-id -i ~/.ssh/id_rsa.pub  user@server

#2


进入主配置文件看看,是不是密码认证没有关掉

#3


引用 2 楼 miltonzhong 的回复:
进入主配置文件看看,是不是密码认证没有关掉
请问你所说的主配置文件指的是哪个文件?

#4


sshd_config:PasswordAuthentication yes

#5


还有将.ssh/known_host的03机删除了试试

#6


引用 4 楼 huarc 的回复:
sshd_config:PasswordAuthentication yes
谢谢回答。我刚查看了一下,这个参数已经是YES了。
之前我打通过两台机器通道的,前几天有人更改了03号机器的ROOT密码,不过后来又改回来了,然后我再进行打通就一直没成功过,不知道这个会不会有什么影响

#7


引用 5 楼 huarc 的回复:
还有将.ssh/known_host的03机删除了试试
我把02号机器.ssh/known_host的03相关信息删除以后,然后重新往03跳转,情况如下:
[wanghai01@tc-crm-rd02.tc..com .ssh]$ ssh wanghai01@tc-crm-rd03.tc
The authenticity of host 'tc-crm-rd03.tc (XXXX)' can't be established.
RSA key fingerprint is 3a:65:d9:31:c1:7b:4d:7d:13:11:a0:d0:ed:6f:32:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'tc-crm-rd03.tc,XXXX' (RSA) to the list of known hosts.
wanghai01@tc-crm-rd03.tc's password:  

仍然提示要输入密码

#8


sshd_config:PasswordAuthentication yes  -->要设置为NO

#9


引用 8 楼 huarc 的回复:
sshd_config:PasswordAuthentication yes  -->要设置为NO
谢谢你的回答啊 
我刚才把03号机的这个参数设置成NO了,依然不行。
而且我刚才看了一下01和02两台机器的配置,这个参数都是YES,也是能互相跳转不提示输入密码的,所以我想可能和这个参数关系并不大。

#10


要不将用户删除,重建立一个新的同名用户试试

或将用户下面的.隐藏文件夹/文件删除了,copy /etc/skel/* 来使用

#11


PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

#1


ssh-keygen -t  rsa 然后可以用ssh-copy-id 这个脚本辅助设置一下
ssh-copy-id -i ~/.ssh/id_rsa.pub  user@server

#2


进入主配置文件看看,是不是密码认证没有关掉

#3


引用 2 楼 miltonzhong 的回复:
进入主配置文件看看,是不是密码认证没有关掉
请问你所说的主配置文件指的是哪个文件?

#4


sshd_config:PasswordAuthentication yes

#5


还有将.ssh/known_host的03机删除了试试

#6


引用 4 楼 huarc 的回复:
sshd_config:PasswordAuthentication yes
谢谢回答。我刚查看了一下,这个参数已经是YES了。
之前我打通过两台机器通道的,前几天有人更改了03号机器的ROOT密码,不过后来又改回来了,然后我再进行打通就一直没成功过,不知道这个会不会有什么影响

#7


引用 5 楼 huarc 的回复:
还有将.ssh/known_host的03机删除了试试
我把02号机器.ssh/known_host的03相关信息删除以后,然后重新往03跳转,情况如下:
[wanghai01@tc-crm-rd02.tc..com .ssh]$ ssh wanghai01@tc-crm-rd03.tc
The authenticity of host 'tc-crm-rd03.tc (XXXX)' can't be established.
RSA key fingerprint is 3a:65:d9:31:c1:7b:4d:7d:13:11:a0:d0:ed:6f:32:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'tc-crm-rd03.tc,XXXX' (RSA) to the list of known hosts.
wanghai01@tc-crm-rd03.tc's password:  

仍然提示要输入密码

#8


sshd_config:PasswordAuthentication yes  -->要设置为NO

#9


引用 8 楼 huarc 的回复:
sshd_config:PasswordAuthentication yes  -->要设置为NO
谢谢你的回答啊 
我刚才把03号机的这个参数设置成NO了,依然不行。
而且我刚才看了一下01和02两台机器的配置,这个参数都是YES,也是能互相跳转不提示输入密码的,所以我想可能和这个参数关系并不大。

#10


要不将用户删除,重建立一个新的同名用户试试

或将用户下面的.隐藏文件夹/文件删除了,copy /etc/skel/* 来使用

#11


PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys