Skip to content

Instantly share code, notes, and snippets.

@sbatururimi
Forked from HacKanCuBa/sshd_config
Last active January 10, 2019 10:10
Show Gist options
  • Save sbatururimi/a0368b71f4fa9aaa9c116a2eed3c228a to your computer and use it in GitHub Desktop.
Save sbatururimi/a0368b71f4fa9aaa9c116a2eed3c228a to your computer and use it in GitHub Desktop.
Modern secure SSH daemon config
# Modern secure (OpenSSH Server 7+) SSHd config by HacKan
# Refer to the manual for more info: https://www.freebsd.org/cgi/man.cgi?sshd_config(5)
# Server fingerprint
# Regenerate with: ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa -b 4096
HostKey /etc/ssh/ssh_host_rsa_key
# Regerate with: ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t ed25519
HostKey /etc/ssh/ssh_host_ed25519_key
# Log for audit, even users' key fingerprint
LogLevel VERBOSE
UsePrivilegeSeparation sandbox
# Ciphers and keying
RekeyLimit 1G 1H
KexAlgorithms [email protected],diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr
MACs [email protected],[email protected],[email protected]
# Limit sessions and its duration
MaxAuthTries 2
MaxSessions 5
ClientAliveInterval 30
ClientAliveCountMax 6
TCPKeepAlive no
UsePAM yes
PasswordAuthentication no
ChallengeResponseAuthentication no
PubkeyAuthentication yes
# You can request for several auth methods to grant access, one next to the other
#AuthenticationMethods publickey
# Enable AllowAgentForwarding if you need to jump through this host
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
PrintMotd no
Compression no
# Only if you really need it:
#AcceptEnv LANG LC_*
# For Arch Linux
# Subsystem sftp /usr/lib/ssh/sftp-server
# For Debian/Ubuntu
Subsystem sftp /usr/lib/openssh/sftp-server -f AUTHPRIV -l INFO
# Restrict SSH usage
#AllowUsers <your username>
# Or restrict by group
AllowGroups ssh-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment