sshd_selinux(8)

πŸ“¦
version 20250627+git412.dbf877ab7 Β· 7 versions
, in opensuse-leap 16.0

πŸ’… NAME πŸ’…

okay so this is sshd_selinux β€” the Security Enhanced Linux Policy for the sshd processes. that's the whole vibe. πŸ’–


✨ DESCRIPTION ✨

Security-Enhanced Linux secures the sshd processes via flexible mandatory access control. yes bestie, mandatory β€” not the cute optional kind. πŸ‘‘

The sshd processes execute with the sshd_t SELinux type. wanna check if you've got these processes running? just run the ps command with the -Z qualifier. easy.

for example:

ps -eZ | grep sshd_t

that's it. that's the check. 🫢


πŸšͺ ENTRYPOINTS πŸšͺ

The sshd_t SELinux type can be entered via the sshd_exec_t file type. that's the door, basically. πŸšͺ✨

the default entrypoint paths for the sshd_t domain are the following:

/usr/bin/sshd, /usr/bin/gsisshd

πŸŽ€ PROCESS TYPES πŸŽ€

SELinux defines process types (domains) for each process running on the system. every process gets a little label, it's giving name-tag energy. 🏷️

you can see the context of a process using the -Z option to ps.

Policy governs the access confined processes have to files. SELinux sshd policy is very flexible β€” it literally lets users set up their sshd processes in as secure a method as possible. obsessed. πŸ’œ

the following process types are defined for sshd:

sshd_t, sshd_sandbox_t, sshd_net_t, ssh_keygen_t, sshd_keygen_t, sshd_session_t, sshd_auth_t, ssh_t, ssh_keysign_t
Note: semanage permissive -a sshd_t can be used to make the process type sshd_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated. so like, it won't block anything but it will still be writing in its diary about it. 😭

πŸ”₯ BOOLEANS πŸ”₯

SELinux policy is customizable based on least access required. sshd policy is extremely flexible and has several booleans that allow you to manipulate the policy and run sshd with the tightest access possible. tightest access = main character energy, no cap. πŸ”₯

  • ssh_sysadm_login β€” if you want to allow ssh logins as sysadm_r:sysadm_t, you must turn on the ssh_sysadm_login boolean. Disabled by default.
setsebool -P ssh_sysadm_login 1
  • ssh_use_tcpd β€” if you want to allow sshd to use tcp wrappers, you must turn on the ssh_use_tcpd boolean. Disabled by default.
setsebool -P ssh_use_tcpd 1
  • daemons_dontaudit_scheduling β€” if you want to dontaudit all daemons scheduling requests (setsched, sys_nice), you must turn on the daemons_dontaudit_scheduling boolean. Enabled by default.
setsebool -P daemons_dontaudit_scheduling 1
  • fips_mode β€” if you want to allow all domains to execute in fips_mode, you must turn on the fips_mode boolean. Enabled by default.
setsebool -P fips_mode 1
  • kerberos_enabled β€” if you want to allow confined applications to run with kerberos, you must turn on the kerberos_enabled boolean. Enabled by default.
setsebool -P kerberos_enabled 1
  • nis_enabled β€” if you want to allow system to run with NIS, you must turn on the nis_enabled boolean. Disabled by default.
setsebool -P nis_enabled 1
  • polyinstantiation_enabled β€” if you want to enable polyinstantiated directory support, you must turn on the polyinstantiation_enabled boolean. Disabled by default.
setsebool -P polyinstantiation_enabled 1

🌈 PORT TYPES 🌈

SELinux defines port types to represent TCP and UDP ports. yes, the ports have types too. everyone's labeled. πŸ’…

you can see the types associated with a port by using the following command:

semanage port -l

Policy governs the access confined processes have to these ports. SELinux sshd policy is very flexible β€” it lets users set up their sshd processes in as secure a method as possible. 🫢

the following port types are defined for sshd:

  • ssh_port_t β€” Default Defined Ports: tcp 22

πŸ“ MANAGED FILES πŸ“

The SELinux process type sshd_t can manage files labeled with the following file types. the paths listed are the default paths for these file types. and hey β€” the processes UID still needs to have DAC permissions. don't forget that part, bestie. πŸ™ˆ

  • auth_cache_t
/var/cache/coolkey(/.*)?
  • auth_home_t
/root/.yubico(/.*)?
/root/.config/Yubico(/.*)?
/root/.google_authenticator
/root/.google_authenticator~
/home/[^/]+/.yubico(/.*)?
/home/[^/]+/.config/Yubico(/.*)?
/home/[^/]+/.google_authenticator
/home/[^/]+/.google_authenticator~
  • cifs_t
  • cluster_conf_t
/etc/cluster(/.*)?
  • cluster_var_lib_t
/var/lib/pcsd(/.*)?
/var/lib/cluster(/.*)?
/var/lib/openais(/.*)?
/var/lib/pengine(/.*)?
/var/lib/corosync(/.*)?
/usr/lib/heartbeat(/.*)?
/var/lib/heartbeat(/.*)?
/var/lib/pacemaker(/.*)?
  • cluster_var_run_t
/run/crm(/.*)?
/run/cman_.*
/run/rsctmp(/.*)?
/run/aisexec.*
/run/heartbeat(/.*)?
/run/pcsd-ruby.socket
/run/corosync-qnetd(/.*)?
/run/corosync-qdevice(/.*)?
/run/pcsd.socket
/run/corosync.pid
/run/cpglockd.pid
/run/rgmanager.pid
/run/cluster/rgmanager.sk
  • condor_var_lib_t
/var/lib/condor(/.*)?
/var/lib/condor/spool(/.*)?
/var/lib/condor/execute(/.*)?
  • ecryptfs_t
/home/[^/]+/.Private(/.*)?
/home/[^/]+/.ecryptfs(/.*)?
  • faillog_t
/var/log/btmp.*
/run/faillock(/.*)?
/var/log/faillog.*
/var/log/tallylog.*
  • fusefs_t
/run/user/[0-9]+/gvfs
  • gitosis_var_lib_t
/srv/gitolite(3)?(/.*)?
/srv/lib/gitosis(/.*)?
/var/lib/gitosis(/.*)?
  • initrc_var_run_t
/run/sysconfig(/.*)?
/run/utmp
/run/keymap
/run/numlock-on
/run/setleds-on
/run/runlevel.dir
/run/setmixer_flag
/run/bootsplashctl
  • kadmind_tmp_t
/var/tmp/kadmin_0
/var/tmp/kiprop_0
  • krb5_host_rcache_t
/var/tmp/krb5_0.rcache2
/var/cache/krb5rcache(/.*)?
/var/tmp/nfs_0
/var/tmp/DNS_25
/var/tmp/host_0
/var/tmp/imap_0
/var/tmp/HTTP_23
/var/tmp/HTTP_48
/var/tmp/ldap_55
/var/tmp/ldap_487
/var/tmp/ldapmap1_0
  • nfs_t
  • openshift_tmp_t
/var/lib/openshift/.*/.tmp(/.*)?
/var/lib/openshift/.*/.sandbox(/.*)?
/var/lib/stickshift/.*/.tmp(/.*)?
/var/lib/stickshift/.*/.sandbox(/.*)?
  • pam_var_run_t
/var/(db|adm)/sudo(/.*)?
/run/sudo(/.*)?
/run/pam_ssh(/.*)?
/run/sepermit(/.*)?
/var/lib/sudo(/.*)?
/run/pam_mount(/.*)?
/run/pam_timestamp(/.*)?
  • root_t
/sysroot/.aleph-version.json
/sysroot/ostree/deploy/.*-atomic/deploy(/.*)?
/
/initrd
/var/lib/ntp
  • security_t
/selinux
  • sshd_var_run_t
/run/sshd.pid
/run/sshd.init.pid
  • systemd_passwd_var_run_t
/run/systemd/ask-password(/.*)?
/run/systemd/ask-password-block(/.*)?
  • user_tmp_t
/run/tlog(/.*)?
/run/user/[^/]+
/dev/shm/mono.*
/tmp/.ICE-unix(/.*)?
/tmp/.X11-unix(/.*)?
/dev/shm/pulse-shm.*
/run/user
/tmp/.X0-lock
/tmp/hsperfdata_root
/var/tmp/hsperfdata_root
/home/[^/]+/tmp
/home/[^/]+/.tmp
/run/user/[0-9]+
/tmp/gconfd-[^/]+
  • user_tmp_type β€” all user tmp files
  • var_auth_t
/var/ace(/.*)?
/var/rsa(/.*)?
/var/lib/abl(/.*)?
/var/lib/rsa(/.*)?
/var/lib/pam_ssh(/.*)?
/var/lib/pam_shield(/.*)?
/var/opt/quest/vas/vasd(/.*)?
/var/lib/google-authenticator(/.*)?
  • wtmpdb_journal_t
/var/lib/wtmpdb/wtmp.db-journal

πŸ¦‹ FILE CONTEXTS πŸ¦‹

SELinux requires files to have an extended attribute to define the file type. every file's gotta have its little label, it's giving ✨identity✨. πŸ¦‹

you can see the context of a file using the -Z option to ls.

Policy governs the access confined processes have to these files. SELinux sshd policy is very flexible β€” it allows users to set up their sshd processes in as secure a method as possible. πŸ’œ

⭐ STANDARD FILE CONTEXT ⭐

SELinux defines the file context types for the sshd. if you wanted to store files with these types in a different paths, you need to execute the semanage command to specify alternate labeling and then use restorecon to put the labels on disk. like this:

semanage fcontext -a -t sshd_keygen_exec_t '/srv/sshd/content(/.*)?'
restorecon -R -v /srv/mysshd_content
Note: SELinux often uses regular expressions to specify labels that match multiple files. regex girlies rise. 😭

the following file types are defined for sshd:

  • sshd_auth_exec_t β€” set files with the sshd_auth_exec_t type, if you want to transition an executable to the sshd_auth_t domain.
  • sshd_exec_t β€” set files with the sshd_exec_t type, if you want to transition an executable to the sshd_t domain.

Paths:

/usr/bin/sshd, /usr/bin/gsisshd
  • sshd_initrc_exec_t β€” set files with the sshd_initrc_exec_t type, if you want to transition an executable to the sshd_initrc_t domain.
  • sshd_key_t β€” set files with the sshd_key_t type, if you want to treat the files as sshd key data.

Paths:

/etc/ssh/ssh_host.*_key, /etc/ssh/ssh_host.*_key.pub,
/etc/ssh/primes
  • sshd_keygen_exec_t β€” set files with the sshd_keygen_exec_t type, if you want to transition an executable to the sshd_keygen_t domain.

Paths:

/usr/libexec/(open)?ssh/sshd-keygen, /usr/bin/sshd-keygen,
/usr/bin/sshd-gen-keys-start
  • sshd_keygen_unit_file_t β€” set files with the sshd_keygen_unit_file_t type, if you want to treat the files as sshd keygen unit content.
  • sshd_keytab_t β€” set files with the sshd_keytab_t type, if you want to treat the files as kerberos keytab files.
  • sshd_session_exec_t β€” set files with the sshd_session_exec_t type, if you want to transition an executable to the sshd_session_t domain.
  • sshd_session_tmpfs_t β€” set files with the sshd_session_tmpfs_t type, if you want to store sshd session files on a tmpfs file system.
  • sshd_session_var_run_t β€” set files with the sshd_session_var_run_t type, if you want to store the sshd session files under the /run or /var/run directory.
  • sshd_tmpfs_t β€” set files with the sshd_tmpfs_t type, if you want to store sshd files on a tmpfs file system.
  • sshd_unit_file_t β€” set files with the sshd_unit_file_t type, if you want to treat the files as sshd unit content.
  • sshd_var_run_t β€” set files with the sshd_var_run_t type, if you want to store the sshd files under the /run or /var/run directory.

Paths:

/run/sshd.pid, /run/sshd.init.pid
Note: file context can be temporarily modified with the chcon command. if you want to permanently change the file context you need to use the semanage fcontext command. this will modify the SELinux labeling database. and then you'll need to use restorecon to apply the labels. so like, chcon is the quick fix and semanage fcontext + restorecon is the actual glow-up. πŸ’…

πŸ’¬ COMMANDS πŸ’¬

okay so like, you can also do all this stuff by hand with the semanage girlies, and honestly they're kinda the moment:

  • semanage fcontext β€” this one can also be used to manipulate default file context mappings. yup, the whole mapping situation, yours to mess with πŸ’…
  • semanage permissive β€” can also be used to manipulate whether or not a process type is permissive. so if you wanna decide which types get to vibe in permissive mode, this is her ✨
  • semanage module β€” can also be used to enable/disable/install/remove policy modules. literal queen behavior, she does it all 🫢
  • semanage port β€” can also be used to manipulate the port definitions. ports, but make it curated πŸŽ€
  • semanage boolean β€” can also be used to manipulate the booleans. yes bestie, the toggles. the on/off girlies. she handles them 🌸
  • system-config-selinux β€” a GUI tool available to customize SELinux policy settings. for when you want to click instead of type, no judgment, we love a visual era πŸ–₯οΈπŸ’–

πŸ‘‘ AUTHOR πŸ‘‘

this manual page was auto-generated using sepolicy manpage. slay, honestly β€” the robots did the homework so we didn't have to πŸ’€βœ¨


πŸ”— SEE ALSO πŸ”—

go read these next, bestie, they're all connected iykyk:


that's the whole page, bestie!! πŸŽ‰ the source is sshd, the version/date situation is 26-10-06, and it's all living under the page name sshd_selinux(8) β€” go forth and be iconic with your contexts πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from