skriptfabrik.sshd
Ansible ロール: sshd
説明
このロールは、セキュアなSSHクライアントとSSHサーバーの設定を提供します。これはDevSec SSHベースラインに準拠することを目的としています。
このロールはarillso.sshdのフォークです。
インストール
ansible-galaxy collection install community.crypto
ansible-galaxy install skriptfabrik.sshd
必要条件
特になし
ロール変数
ssh_ipv6_enable
IPv6が必要な場合はtrue
ssh_ipv6_enable: '{{ network_ipv6_enable | default(false) }}' # sshd + ssh
ssh_server_enabled
sshdを開始し、有効にする場合はtrue
ssh_server_enabled: true # sshd
ssh_use_dns
DNS解決が必要な場合はtrue、リモートホスト名を検索します。デフォルトはfalse(6.8から)
ssh_use_dns: false # sshd
ssh_compression
圧縮が必要な場合はtrueまたは値を指定
ssh_compression: false # sshd
ssh_hardening
どのコンポーネント(クライアントおよびサーバー)に対して設定を生成するかを指定できます。SSHサーバーのないクライアントで実行する場合に便利です。
ssh_client_hardening: true # ssh
ssh_server_hardening: true # sshd
ssh_client_password_login
trueの場合、パスワードログインが許可されます。
ssh_client_password_login: false # ssh
ssh_server_password_login: false # sshd
ssh_server_ports
sshサーバーがリッスンすべきポート
ssh_server_ports: ['22'] # sshd
ssh_client_port
sshクライアントが接続するポート
ssh_client_port: '22' # ssh
ssh_listen_to
sshサーバーがリッスンする1つまたは複数のIPアドレス。デフォルトは空ですが、セキュリティ上の理由で構成すべきです!
ssh_listen_to: ['0.0.0.0'] # sshd
ssh_host_key_files
sshdを起動する際に探すホストキー。
ssh_host_key_files: [] # sshd
ssh_force_create_host_key_files
ホストキーファイルの作成を強制します。
ssh_force_create_host_key_files: false # sshd
ssh_max_auth_retries
接続ごとに許可される最大認証試行回数を指定します。この値の半分に達すると、追加の失敗が記録されます。
ssh_max_auth_retries: 2
ssh_client_alive_interval
ssh_client_alive_interval: 300 # sshd
ssh_client_alive_count
ssh_client_alive_count: 3 # sshd
ssh_permit_tunnel
SSHトンネルを許可します。
ssh_permit_tunnel: false
ssh_remote_hosts
カスタムオプションを持つホスト。 # ssh
ssh_remote_hosts: []
例
ssh_remote_hosts:
- names: ['example.com', 'example2.com']
options: ['Port 2222', 'ForwardAgent yes']
- names: ['example3.com']
options: ['StrictHostKeyChecking no']
ssh_allow_root_with_key
この値を"without-password"または"yes"に設定すると、rootのログインが許可されます。
ssh_allow_root_with_key: 'no' # sshd
ssh_allow_tcp_forwarding
TCPフォワーディングを無効にするにはfalse、許可するにはtrueに設定します。
ssh_allow_tcp_forwarding: false # sshd
ssh_gateway_ports
非ループバックアドレスに転送ポートをバインドすることを無効にするにはfalse、ワイルドカードアドレスでのバインディングを強制するにはtrueに設定します。
セットを'clientspecified'にすると、クライアントがバインドするアドレスを指定できます。
ssh_gateway_ports: false # sshd
ssh_allow_agent_forwarding
エージェントフォワーディングを無効にするにはfalse、許可するにはtrueに設定します。
ssh_allow_agent_forwarding: false # sshd
ssh_pam_support
SSHがPAMサポートを持つ場合はtrue
ssh_pam_support: true
ssh_use_pam
pam認証を無効にするにはfalseを設定します。
ssh_use_pam: false # sshd
ssh_google_auth
Google 2FA認証を無効にするにはfalseを設定します。
ssh_google_auth: false # sshd
ssh_pam_device
pamデバイス2FA入力を無効にするにはfalseを設定します。
ssh_pam_device: false # sshd
ssh_gssapi_support
SSHがGSSAPIをサポートする場合はtrue
ssh_gssapi_support: false
ssh_kerberos_support
SSHがKerberosをサポートする場合はtrue
ssh_kerberos_support: true
ssh_deny_users
指定された場合、指定されたパターンのユーザー名でのログインは拒否されます。
ssh_deny_users: '' # sshd
ssh_allow_users
指定された場合、指定されたパターンのユーザー名でのみログインが許可されます。
ssh_allow_users: '' # sshd
ssh_deny_groups
指定された場合、プライマリグループまたは補助グループのリストが指定されたパターンに一致するユーザーはログインできません。
ssh_deny_groups: '' # sshd
ssh_allow_groups
指定された場合、プライマリグループまたは補助グループのリストが指定されたパターンに一致するユーザーのみログインが許可されます。
ssh_allow_groups: '' # sshd
ssh_authorized_keys_file
ユーザー認証に使用できる公開鍵を含むデフォルトのファイルを変更します。
ssh_authorized_keys_file: '' # sshd
ssh_trusted_user_ca_keys_file
ユーザー証明書に署名するために使用される信頼された証明書機関の公開鍵を含むファイルを指定します。
ssh_trusted_user_ca_keys_file: '' # sshd
ssh_trusted_user_ca_keys
ユーザー証明書に署名するために使用される信頼された証明書機関の公開鍵を設定します。
ssh_trusted_user_ca_keys: [] # sshd
例
ssh_trusted_user_ca_keys:
- 'ssh-rsa ... comment1'
- 'ssh-rsa ... comment2'
ssh_authorized_principals_file
許可されているプリンシパルを含むファイルを指定します。ssh_trusted_user_ca_keys_fileが設定されている場合にのみ使用されます。
ssh_authorized_principals_file: '' # sshd
例
ssh_authorized_principals_file: '/etc/ssh/auth_principals/%u'
%hは認証されているユーザーのホームディレクトリに置き換えられ、%uはそのユーザーのユーザー名に置き換えられます。展開後、パスは絶対パスまたはユーザーのホームディレクトリに相対的なパスとして扱われます。
ssh_authorized_principals
ファイルパスと認可されたプリンシパルを含むハッシュのリスト。ssh_authorized_principals_fileが設定されている場合にのみ使用されます。
ssh_authorized_principals: [] # sshd
例
ssh_authorized_principals:
- {
path: '/etc/ssh/auth_principals/root',
principals: ['root'],
owner: '{{ ssh_owner }}',
group: '{{ ssh_group }}',
directoryowner: '{{ ssh_owner }}',
directorygroup: '{{ ssh_group}}',
}
- {
path: '/etc/ssh/auth_principals/myuser',
principals: ['masteradmin', 'webserver'],
}
ssh_print_motd
MOTDの表示を無効にするにはfalseを設定します。
ssh_print_motd: false # sshd
ssh_print_last_log
最終ログイン情報の表示を無効にするにはfalseを設定します。
ssh_print_last_log: false # sshd
ssh_banner
認証が許可される前に/etc/ssh/banner.txtを提供することを無効にするにはfalseを設定します。
ssh_banner: false # sshd
ssh_print_debian_banner
初期プロトコルハンドシェイク中のディストリビューションバージョン漏洩を無効にするにはfalseを設定します。
ssh_print_debian_banner: false # sshd (Debian OSファミリーのみ)
ssh_sftp_enabled
sftp設定を有効にする場合はtrue
ssh_sftp_enabled: '{{ sftp_enabled | default(false) }}'
ssh_sftp_chroot
sftp chrootを無効にするにはfalseを設定します。
ssh_sftp_chroot: '{{ sftp_chroot | default(true) }}'
ssh_sftp_chroot_dir
デフォルトのsftp chroot場所を変更します。
ssh_sftp_chroot_dir: "{{ sftp_chroot_dir | default('/home/%u') }}"
SFTP用にパスワードログインを許可するには、trueに設定します。
ssh_server_sftp_password_login: false
ssh_server_sftp_password_login: true
ssh_client_roaming
実験的なクライアントローミングを有効にします。
ssh_client_roaming: false
ssh_server_match_user
Match Userブロックを生成するためのユーザーとルールを含むハッシュのリスト。
ssh_server_match_user: false # sshd
ssh_server_match_group
Match Groupブロックを生成するためのグループとルールを含むハッシュのリスト。
ssh_server_match_group: false # sshd
ssh_server_match_address
Match Addressブロックを生成するためのアドレス/サブネットとルールを含むハッシュのリスト。
ssh_server_match_address: false # sshd
ssh_server_permit_environment_vars
ssh_server_permit_environment_vars: false
ssh_max_startups
SSHデーモンへの同時未認証接続の最大数
ssh_max_startups: '10:30:100' # sshd
ssh_ps53
ssh_ps53: 'yes'
ssh_ps59
ssh_ps59: 'sandbox'
ssh_macs
ssh_macs: []
ssh_ciphers
ssh_ciphers: []
ssh_kex
ssh_kex: []
ssh_macs_53_default
ssh_macs_53_default:
- hmac-ripemd160
- hmac-sha1
ssh_macs_59_default
ssh_macs_59_default:
- hmac-sha2-512
- hmac-sha2-256
- hmac-ripemd160
ssh_macs_66_default
ssh_macs_66_default:
- [email protected]
- [email protected]
- [email protected]
- hmac-sha2-512
- hmac-sha2-256
ssh_macs_76_default
ssh_macs_76_default:
- [email protected]
- [email protected]
- [email protected]
- hmac-sha2-512
- hmac-sha2-256
ssh_ciphers_53_default
ssh_ciphers_53_default:
- aes256-ctr
- aes192-ctr
- aes128-ctr
ssh_ciphers_66_default
ssh_ciphers_66_default:
- [email protected]
- [email protected]
- [email protected]
- aes256-ctr
- aes192-ctr
- aes128-ctr
ssh_kex_59_default
ssh_kex_59_default:
- diffie-hellman-group-exchange-sha256
ssh_kex_66_default
ssh_kex_66_default:
- [email protected]
- diffie-hellman-group-exchange-sha256
ssh_custom_selinux_dir
ssh_passwordポリシーを保存するディレクトリ
ssh_custom_selinux_dir: '/etc/selinux/local-policies'
sshd_moduli_file: '/etc/ssh/moduli'
sshd_moduli_minimum: 2048
ssh_challengeresponseauthentication
ChallengeResponseAuthenticationを無効にします。
ssh_challengeresponseauthentication: false
ssh_server_revoked_keys
sshサーバーによって決して受け入れられない公開鍵のリストです。
ssh_server_revoked_keys: []
ssh_hardening_enabled
このロールを無効にするにはfalseに設定します。Ansibleロールの依存メカニズムを使用する際に便利です。
ssh_hardening_enabled: true
ssh_custom_options
SSHクライアント設定ファイルのカスタムオプション
ssh_custom_options: []
sshd_custom_options
SSHデーモン設定ファイルのカスタムオプション
sshd_custom_options: []
依存関係
特になし
例のプレイブック
- hosts: all
roles:
- skriptfabrik.sshd
作者
ライセンス
このプロジェクトはMITライセンスの下にあります。
著作権
(c) 2022, skriptfabrik GmbH
This role provides secure ssh-client and ssh-server configurations. It is intended to be compliant with the DevSec SSH Baseline.
ansible-galaxy install skriptfabrik.sshd