たまたまなのかセットアップしようとした3750XがSSHが有効化になっておりRSAキーが設定されていました。
ホスト名とドメイン名を設定しないとできないと思っていましたが最近ではそうじゃないのかな?
RSAキーを消すだけでdisableにできるのでとりあえず有効化する方法と無効化する方法をメモしてみました。
●sshを使う為の設定
–ユーザーの作成–
一般的にパスワード認証が多いと思いますのでパスワード認証の設定
Switch#configure terminal
Switch(config)#username admin password pass
VTYポートにログインした際にline vtyに設定されたパスワードではなく上記設定を使うようにローカル認証設定にします。
※vtyポート数は自分の環境に合わせて下さい
Switch(config)#line vty 0 4
Switch(config-line)#login local
–ホスト名ドメイン名の作成–
ssh暗号化鍵作成の為のホスト名とドメイン名を作成します。
※もしかしたらSwitchによっていは要らないのかも?
Switch(config)#hostname test
test(config)#ip domain-name test.co.jp
–RSA暗号鍵の作成–
鍵長のサイズはよく1024にするので1024にしています。
デフォルトの512でも何の問題もないです
test(config)#crypto key generate rsa
The name for the keys will be: test.test.co.jp
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]:1024
% Generating 1024 bit RSA keys, keys will be non-exportable…[OK]
SSHのバージョン指定したい場合は下記のコマンドを追加
セキュリティ的に高いversion2にしています
test(config)#ip ssh version 2
telnetを禁止してSSHのみにする場合は下記のコマンドを追加
Switch(config)#line vty 0 4
Switch(config-line)#transport input ssh
–確認–
RSA鍵がああるかは下記のコマンドで確認
Switch#show ip ssh
SSH Enabled – version 1.99
Authentication timeout: 120 secs; Authentication retries: 3
Minimum expected Diffie Hellman key size : 1024 bits
IOS Keys in SECSH format(ssh-rsa, base64 encoded):
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQC4IgvQ28WLlvw5pU5SnKVE8pXxWM4mYMMmQxK7an5y
LCIrPJF7eJfrM+siy9NbeKXXaUrrBppmno4IzgAPBsgF
SSH接続は以上ですが、SSHで特権execモードに移行する為にはenable paswordコマンドかenable secretコマンドでパスワード設定して下さい。
–SSHの無効化–
RSA鍵を消せば自動的にdisabledになります。
Switch#configure terminal
Switch(config)#crypto key zeroize rsa
% All RSA keys will be removed.
% All router certs issued using these keys will also be removed.
Do you really want to remove these keys? [yes/no]: yes
–確認–
Switch#sh ip ssh
SSH Disabled – version 1.99
%Please create RSA keys to enable SSH (and of atleast 768 bits for SSH v2).
Authentication timeout: 120 secs; Authentication retries: 3
Minimum expected Diffie Hellman key size : 1024 bits
IOS Keys in SECSH format(ssh-rsa, base64 encoded): NONE
やったことないけどデフォルトがdisabledであればssh制御パラーメータを戻してもいいかもしれません。
Switch#configure terminal
Switch(config)#no ip ssh { timeout | authentication-retries }