|
|
1)停止 sshd 服务。
. Q, Q$ {' v& N# z& w& i% s' l2 _3 p+ g
service ssh stop
. c: {+ r1 A; z( @+ @2)手动 debug 模式运行 sshd 。3 C' @* r4 e7 u ]% V# n6 g4 W& ?
% K' K1 s0 c9 N+ I/usr/sbin/sshd -d -p 229 C4 h) S8 G9 d: L3 t6 x* a
3)运行失败,报错:$ e. _- X+ n3 `. Y7 K
" @4 Y6 K) D3 ^) O+ [9 J- a1 s
Could not load host key: /etc/ssh/ssh_host_ed25519_key
! t, Y4 {4 j3 X2 T7 J5 h/ Y( X+ GMissing privilege separation directory: /run/sshd
3 C1 o5 v$ ~4 s- n4)添加 -h /etc/ssh/ssh_host_rsa_key 参数消除第1个报错。% c0 j# j I1 T0 O; E
3 u W( N; h/ D" w3 r5)运行命令 mkdir systemd-tmpfiles --create 消除第2个报错。: n E" s/ R, [3 G
V2 j4 c+ ?) z' x2 t% @/ E6)用下面的命令成功运行 ssh 。
9 o) d) X. i, V
6 J2 J5 U9 n& E* R% x; i/usr/sbin/sshd -d -p 22 -h /etc/ssh/ssh_host_rsa_key/ c% a( G* r8 s7 T; g4 }5 X5 Y
7)客户端 ssh 登录,手动 debug 模式运行的 sshd 报错。
( e( ^7 f4 C5 F) J0 B# ]. l" T. G" I
2 \! c4 b6 k( l) ldebug1: list_hostkey_types: [preauth]
7 E `' Q4 x; ?, D& bNo supported key exchange algorithms [preauth]9 e# N& T+ F& o* M, m, r
debug1: do_cleanup [preauth]
6 N9 I3 b6 C- L( R$ ]9 W8)从上面的报错信息找到线索,通过下面的操作解决了问题。
7 V9 z% U7 ~. { X6 {, X1 R
" I [% o2 e8 T* W; u! q/ l4 S2 i2 g删除 .ssh 目录
* U+ R" X1 e6 ~+ P2 `. Yrm -rf ~/.ssh; z& h2 @6 G, U) A
重新生成 ssh key5 @; x* L, H8 O& G' A/ x
ssh-keygen -t rsa* [2 ?1 e! U, V$ [$ N! c/ R/ r, O
重新添加客户端 ssh 公钥到 authorized_keys! _- }4 x K5 N1 J, Q! z; a
vi ~/.ssh/authorized_keys5 w j6 U& t/ R
启动 sshd5 j+ H, p. I4 o+ i+ K
service ssh start |
|