以前に IOS-XR(Cisco ASR 9000)へ公開鍵認証方式を使い、パスワード無しで SSH ログインする というメモを書きました。今回は従来の IOS で鍵ペアを用いてパスワード無しで SSH ログインする設定をメモしておきます。検証は VIRL 上の IOS 15.6(2)T で行いました。
ip ssh pubkey-chain で公開鍵を登録します。但し、一行の文字列が長すぎると弾かれてしまいます。そこで、公開鍵の文字列は適当な長さで改行して入力します。具体的な設定例は以下の通りです。
hostname IOSV-1
ip domain-name EXAMPLE.LOCAL
!
aaa new-model
!
ip ssh version 2
ip ssh pubkey-chain
username USERNAME
key-string ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxx USERNAME@localhost
!
ip ssh server algorithm authentication publickey password keyboard
ip ssh server algorithm publickey ssh-rsa
!
interface GigabitEthernet0/1
ip address 192.168.1.1 255.255.255.0
no shutdown
!
access-list 1 permit 192.168.1.0 0.0.0.255
!
line vty 0 4
access-class 1 in
transport input ssh
!
crypto key generate rsa modulus 2048
!
end
認証方式の選択
認証方式は以下のいずれかから選択して設定します。ip ssh pubkey-chain 配下に username が定義してあるので、グローバルに username の定義を行う必要は無いようです。
公開鍵認証方式だけを使う場合
ip ssh server algorithm authentication publickey
パスワード認証方式だけを使う場合
ip ssh server algorithm authentication password keyboard
公開鍵認証方式とパスワード認証方式の両方を使う場合
ip ssh server algorithm authentication publickey password keyboard
コメント