password暗号化について

passwordの暗号化について、いろいろな組み合わせを試してみる

特権(enable)パスワードを設定する

パターン1:

no service password-encryption
enable password 7


SW-1(config)#enable password ?
0 Specifies an UNENCRYPTED password will follow
7 Specifies a HIDDEN password will follow
LINE The UNENCRYPTED (cleartext) ‘enable’ password
level Set exec level password

SW-1(config)#enable password 7 ?
WORD The HIDDEN ‘enable’ password string

SW-1(config)#enable password 7 hoge
SW-1(config)#do sh run

(一部抜粋)
no service password-encryption
!
hostname SW-1
!
enable password 7 hoge ←暗号化されない
!

パターン2:
no service password-encryption
enable password 0


SW-1(config)#enable password 0 hoge
SW-1(config)#do sh run

(一部抜粋)
no service password-encryption
!
hostname SW-1
!
enable password hoge ←暗号化されない
!

パターン3:
service password-encryption
enable password 7


SW-1(config)#enable password 7 hoge
SW-1(config)#do sh run
Building configuration…

~省略~
service password-encryption
!
hostname SW-1
!
enable password 7 hoge ←暗号化されない
!

パターン4:
service password-encryption
enable password 0


SW-1(config)#service password-encryption
SW-1(config)#enable password 0 hoge
SW-1(config)#do sh run

(一部抜粋)
service password-encryption
!
hostname SW-1
!
enable password 7 00544A5452 ←暗号化される
!

telnetパスワードを設定する パターン1: no service password-encryption (telnet) password 7 SW-1(config)#line vty 0 4 SW-1(config)#no service password-encryption SW-1(config-line)#password 7 0926 SW-1(config-line)#do sh run (一部抜粋) no service password-encryption ! line con 0 line vty 0 4 password 7 hoge ←暗号化されない パターン2: no service password-encryption (telnet) password 0 SW-1(config)#line vty 0 4 SW-1(config-line)#password 0 hoge SW-1(config-line)#do sh run (一部抜粋) no service password-encryption ! ! line con 0 line vty 0 4 password hoge ←暗号化されない パターン3: service password-encryption (telnet) password 0 SW-1(config)#service password-encryption SW-1(config-line)#password ? 0 Specifies an UNENCRYPTED password will follow 7 Specifies a HIDDEN password will follow LINE The UNENCRYPTED (cleartext) line password SW-1(config-line)#password 7 hoge SW-1(config-line)#do sh run (一部抜粋) service password-encryption ! line con 0 line vty 0 4 password 7 hoge ←暗号化されない パターン4: service password-encryption (telnet) password 0 SW-1(config-line)#password 0 hoge SW-1(config-line)#do sh run (一部抜粋) service password-encryption ! line con 0 line vty 0 4 password 7 040B525459 ←暗号化される 余談ですが、認証の種類は以下のようなものがあります SW-1(config-line)#login ? local Local password checking (USERNAMEが必要となる) tacacs Use tacacs server for password checking  ←telnetでパスワード設定する場合はこちら 認証の種類 ・login → 事前にlineコンフィグレーションモード(config-line)で設定したパスワードを使い認証する ・login local → “username”コマンドで設定したアカウントのみ認証対象となる ・login tacacs → “tacacs”を利用したもののみ認証する 認証方式は一つしか選択できないので、新しく入力したものが上書きしてしまう 例:この順番で入力した場合 login login local login tacacs ↓ line vty 12 exec-timeout 0 0 login tacacs 特権パスワードを暗号化して設定する


SW-1(config)#enable secret ?
0 Specifies an UNENCRYPTED password will follow
5 Specifies an ENCRYPTED secret will follow
LINE The UNENCRYPTED (cleartext) ‘enable’ secret
level Set exec level password

SW-1(config)#enable secret 5 hoge
ERROR: The secret you entered is not a valid encrypted secret.
To enter an UNENCRYPTED secret, do not specify type 5 encryption.
When you properly enter an UNENCRYPTED secret, it will be encrypted.

↑このエラーはMD5で暗号化した文字列でパスワード設定してくれということ

暗号化なしで設定してみる(オプション”0″)


SW-1(config)#enable secret 0 0926
The enable secret you have chosen is the same as your enable password.
This is not recommended. Re-enter the enable secret.

enable password (service password-encryptionで暗号あり)
enable secret password

SW-1(config)#do sh run
Building configuration…

Current configuration : 2026 bytes

(一部抜粋)
hostname SW-1
!
enable secret 5 $1$bNAQ$GTr6z07RmHgwX3e7WCh7T. ← 暗号化された特権パスワード
enable password 7 14474B595A ← 暗号化されていない特権パスワード(service password-encryptionコマンドがきいてる)


上記2つのコマンドは混在できる(両方違うパスワード設定した場合でも、それぞれログインできる)

デフォルトでは enable secret のみが暗号化され、それ以外のパスワードは暗号化されず show run を実行した時に設定したパスワードがそのまま表示されます
そのため、show run で設定情報の確認をしている時に、後ろから他の人にパスワードを盗み見られる可能性があります (これをショルダーハッキングと言う)

【まとめ】

「service password-encryption」で暗号化されるのは、暗号化なしで設定するパスワードのみで
passwordコマンドやsecretコマンドのオプション “7” や “5” などは暗号化するのではなく、暗号化したものをパスワードとして割り当ててるというタグ付けのようなもの

configを機器に流し込むときなど、機器側で判別させるためでもあるので
こういう形になる

よって、通常パスワードを設定するときはこれらのオプションは使わない

尚、service password-encryptionの設定後に新しく設定するパスワードを暗号化する
既存の暗号パス、非暗号パスはそのままとなる

no service password-encryption コマンドはパスワードの暗号化を解除する
このコマンド設定以降、対象となるパスワードは暗号化されない
ただし、既に暗号化されていたパスワードは暗号化されたままです

「enable secret」は「service-password-encryption」より強固な暗号化方式(MD5)を採用しているので、Ciscoはこちらを推奨している

特権パスワードは明示的に「enable secret」で設定を行い
その他のものは「service-password-encryption」が事前に設定されていれば、”0″オプションでパスワード設定すれば暗号化される

タイトルとURLをコピーしました