本事象は他にも記事がありますが部分的なところがありましたので、対処までの一連の流れを書き留めておきます。
環境はCentOS release 6.10 (Final)です。
OpenSSHの詳細は以下です。
[hoge~/.ssh $ ssh -V
OpenSSH_7.7p1, OpenSSL 1.0.1e-fips 11 Feb 2013
1.事象
こちらを踏み台サーバーにしているのですがある日、脆弱性対応としてOpenSSHのupdate行った後SSHでNW機器(JuniperSSG5)にログインしようとしたらエラーが発生しました。
[hoge~/.ssh $ ssh admin@xxx.xxx.xxx.xxx
Unable to negotiate with xxx.xxx.xxx.xxx port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
2.対策(diffie-hellman-group1-sha1)
sshのdiffie-hellman-group1-sha1が使えないのでアクセスできないと言っています。
こちらはユーザーの.sshのconfigファイルに以下を追加して解決しました。
[hoge~/.ssh $ more config
host *
KexAlgorithms +diffie-hellman-group1-sha1
hostはアスタリスクで全部IP指定にしていますが、必要に応じて変更お願いします。
3.対策(暗号認証DAS)
これでsshできるかな、と思ったらまた違うエラーが発生。
[hoge~/.ssh $ ssh admin@xxx.xxx.xxx.xxx
Unable to negotiate with 119.254.113.118 port 22: no matching host key type found. Their offer: ssh-dss
今度のエラーは暗号認証のDAS鍵を使ったSSH接続をOpenSSH7.0以降は非推奨にしていることに起因しているそうです。
参考URL:https://blog.keinos.com/20170703_2635
こちらも同じく.sshのconfigファイルにDAS鍵を使った接続ができるようアルゴリズムを追加します。
host *
KexAlgorithms +diffie-hellman-group1-sha1
HostKeyAlgorithms +ssh-dss ←追加行
4.対策(暗号認証方式)
これで接続できるようになったら思ったらまたエラーが発生。
[hoge~/.ssh $ ssh admin@xxx.xxx.xxx.xxx
Unable to negotiate with xxx.xxx.xxx.xxx port 22: no matching cipher found. Their offer: 3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc
認証方式が対応していません、というエラーのようです。
こちらは/etc/ssh/ssh_configの認証方式の行を有効化して対応します。
# Host *
# ForwardAgent no
# ForwardX11 no
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# IdentityFile ~/.ssh/id_ecdsa
# IdentityFile ~/.ssh/id_ed25519
# Port 22
# Protocol 2
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc →ここの#を削除
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
これでようやくFWにログインできました。
5.FW確認
ログインして見てみると
hoge-fw-> get ssh host-key
DSA fingerprint:
finger_print = f7:a3:18:86:d2:db:b2:b4:bb:79:d9:2e:1c:82:96:7d
FWにDSA鍵が存在してました。
NW機器は古い機器でもUpdateせずにそのまま運用しがちですが、ワールドワイドのIT技術はどんどん新しくなっていくので、UPdateが必要だと思い知らさせました。