Matchディレクティブを使って制御する
仕事で使う機会があったので書いておく。
OpenSSH 4.4以降ではMatchディレクティブを使ってユーザ、グループ、ホスト名、IPアドレスに応じて設定を再定義することが可能。
Matchディレクティブはグローバルの設定よりも優先され、利用できるオプションは下記の通り。
- AllowAgentForwarding
- AllowTcpForwarding
- AuthorizedKeysFile
- AuthorizedPrincipalsFile
- BannerChrootDirectory
- ForceCommand
- GatewayPorts
- GSSAPIAuthentication
- HostbasedAuthentication
- HostbasedUsesNameFromPacketOnly
- KbdInteractiveAuthentication
- KerberosAuthentication
- MaxAuthTries
- MaxSessions
- PasswordAuthentication
- PermitEmptyPasswords
- PermitOpen
- PermitRootLogin
- PermitTunnel
- PubkeyAuthentication
- RhostsRSAAuthentication
- RSAAuthentication
- X11DisplayOffset
- X11Forwarding
- X11UseLocalHost
設定例
PasswordAuthentication no X11Forwarding no Match User hoge PasswordAuthentication yes Match Address 192.168.1.0/24 X11Forwarding yes
詳しくはマニュアルで。
http://www.openbsd.org/cgi-bin/man.cgi?query=sshd_config&sektion=5