User Tools

Site Tools


sshd_config

If you want to send us your comments, please do so. Thanks
More on comments


sshd_config

The server side config file
See man 5 sshd_config
After a change do systemctl restart sshd . Any connection will remain open

See also network security

PAM

PAM stands for Pluggable Authentication Modules. It is a powerful and flexible framework for authentication on Unix-like systems, allowing system administrators to implement a wide range of authentication methods and policies

Some settgings

  • Port change.
    • This is security by obscurity and might not be a good idea.
      • In a few weeks the botnet will have discovered your alternative ssh port and make it useless
    • If you want to change the port number do as root
      • change the Port number in /etc/ssh/ssh_config
      • change the Port number in /etc/ssh/sshd_config

sshd_config on the server

  • AllowUsers user1 user2 Allow only users who need ssh to use it
  • PermitEmptyPasswords no
  • PubkeyAuthentication yes
  • PasswordAuthentication yes as long as it is needed
  • ChallengeResponseAuthentication no
  • AuthenticationMethods publickey password
  • UsePAM no
  • X11Forwarding no, unless a graphical userinterface is used
  • Autologout
    • ClientAliveInterval 1800
    • ClientAliveCountMax 0
  • HostbasedAuthentication no
  • IgnoreRhosts yes
  • ListenAddress IPtheconnectionoriginatesform Mostly this is your router's LAN side IP address since it uses NAT
    • If the router does NAT it might be possible to set the ACL (Access Control List) in the router
    • You can also use denyhosts (not in the Debian repository) or fail2ban if your router exposes the IP address from the WAN side on the LAN side, is in bridge mode.
  • Save
  • Restart ssh use one of
    • systemctl restart sshd
    • Old: /etc/init.d/sshd restart
    • Old: service ssh restart
  • Test if you can login with the key and if you can login with the password

All options

Our recommended settings, change where needed
The allow/deny directives are processed in the following order: DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups. So the ones earlier in the list take precedent over the following

OptionSettingRemark
AcceptEnvLANG LC_*Default for Debian. Otherwise: empty (Do not accept environment variables)
AddressFamilyinetUse IPv4 only
AllowAgentForwardingnoDeny users shell access to be more secure
AllowGroupssshCreate a group ssh and add the useres to it who need ssh access. Space separated list
AllowStreamLocalForwardingnoDeny users shell access to be more secure
AllowTcpForwardingyesDefault
AllowUsersuser1 user2 user3Space separated list
AuthenticationMethodsanyDefault: any (single authentication method) otherwise multiple authentication methods are needed to get access. Comma separated list
AuthorizedKeysCommand
AuthorizedKeysCommandUser
AuthorizedKeysFile
AuthorizedPrincipalsCommand
AuthorizedPrincipalsCommandUser
AuthorizedPrincipalsFile
BannernoneDefault. Send a message to the client before logon
ChallengeResponseAuthenticationnoDefault for Debian. Otherwise “yes”
ChrootDirectorynoneDefault
Cipherschacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.comDefault. Comma separated list
ClientAliveCountMax3Default. Not spoofable. See also ClientAliveInterval
ClientAliveInterval0Default. No messages are sent
CompressionyesDefault
BanneryesDefault
DenyGroups Space separated list
DenyUsers Space separated list
DisableForwarding Leave default. Pressumeably “no”
FingerprintHashsha256Default
ForceCommand
GatewayPortsnoDefault
GSSAPIAuthenticationnoDefault
GSSAPIKeyExchange
GSSAPICleanupCredentials
GSSAPIStrictAcceptorCheck
GSSAPIStoreCredentialsOnRekey
HostbasedAcceptedKeyTypesecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsaComma separated list
HostbasedAuthenticationnoDefault
HostbasedUsesNameFromPacketOnlynoDefault
HostCertificate No file. This is the default
HostKeyfile containing a private host key used by SSHDefaults: /etc/ssh/ssh_host_rsa_key, /etc/ssh/ssh_host_ecdsa_key and /etc/ssh/ssh_host_ed25519_key
HostKeyAgent
HostKeyAlgorithmsecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsa Default
IgnoreRhostsyesDefault
IgnoreUserKnownHostsnoDefault
IPQoSlowdelay throughputDefault. Space separated
KbdInteractiveAuthenticationyesDefault
KerberosAuthenticationnoDefault
KerberosGetAFSToken
KerberosOrLocalPasswd
KerberosTicketCleanup
KexAlgorithmscurve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 Default. Comma separated list
ListenAddress Default: Listen on all local addresses
LoginGraceTime120 secondsDefault
LogLevelINFODefault
MACsumac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1Default. Comma separated list
Match Conditional block
MaxAuthTries6Default
MaxSessions10 Default
MaxStartups10:30:100 Default. start:rate:full
PasswordAuthenticationyesDefault. When the authentication key is functioning set this to “no”
PermitEmptyPasswordsnoDefault
PermitOpenallDefault
PermitRootLoginnoOptions: yes, prohibit-password, without-password, forced-commands-only, or no. Default: prohibit-password
PermitTTYyesDefault
PermitTunnelnoDefault
PermitUserEnvironmentnoDefault
PermitUserRCyesDefault. Executes: ~/.ssh/rc
PidFile/run/sshd.pidDefault
Port22Default
PrintLastLogyesDefault. Print the date and time of the last user login
PrintMotdnoDefault for Debian. Otherwise “yes”. Prints: /etc/motd
PubkeyAcceptedKeyTypesecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsaDefault. Comma separated list
PubkeyAuthenticationyesDefault
RekeyLimitnoneDefault
RevokedKeysnoneDefault
StreamLocalBindMask0177Default
StreamLocalBindUnlinknoDefault
StrictModesyesDefault
Subsystemsftp /usr/lib/openssh/sftp-serverDefault on Debian, otherwise none specified
SyslogFacilityAUTHDefault
TCPKeepAliveyesDefault
TrustedUserCAKeys
UseDNSnoDefault
UsePAMnoIs login with a password is needed ad 'password' to the 'AuthenticationMethods' option
UsePrivilegeSeparationsandboxDefault
VersionAddendumnoneDefault
X11DisplayOffset10Default
X11Forwardingno“yes” is graphics, X windows, is used
X11UseLocalhostyesDefault
XAuthLocation/usr/bin/xauthDefault

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
sshd_config.txt · Last modified: 08-06-2023 15:02 by wim