Imported config file examples, improved ssh's

This commit is contained in:
Michele Cereda
2023-02-12 15:04:20 +01:00
parent 4f8f151509
commit 67c560e174
6 changed files with 283 additions and 77 deletions

88
examples/ssh/ssh_config Normal file
View File

@@ -0,0 +1,88 @@
################################################################################
## ~/.ssh/config
##
## Gotchas:
## - options are applied first-come-first-served, so:
## - specific and higher priority settings go on top, generic and lower ones
## go on the bottom
## - user defaults MUST come last to be treated as such
## - host specificity is NOT a factor of priority
## - multiple host names (and aliases) may be specified per section
## - targets may match multiple host sections and have settings applied in order
## - host sections only apply to the matched names
## - canonicalization forces a configuration reload to check the now canonical
## host name against the configuration
################################################################################
# Canonicalize host names as first thing
# Forces a configuration reload so that only the canonical host name is matched
# against the rest of the configuration
CanonicalizeHostname yes
CanonicalDomains lan localdomain my.org
# 'special' devices
# E.g. work ones
Host net?a?-fw? org?-h?-sw?
CanonicalDomains that.org
CanonicalizeMaxDots 0
Host !bastion* *.brt*.my.org *.brs? *.brs??
AddressFamily inet6
ProxyCommand ssh -W %h:%p `host bastion.my.org | awk '/address/ {print $4; exit}' | xargs host | cut -d\ -f5`
# Connect to secured hosts
# E.g. targets using non-default configuration
Host *-bastion-* *-fw
IdentitiesOnly yes
IdentityFile ~/.ssh/id_rsa
Port 2222
# Avoid OS incompatibility nuisances
# E.g. LANG not set when connecting to Linux from Darwin
Host linux-* raspberrypi?
SendEnv -LC_* PAGER
SetEnv LANG=C LANGUAGE=en LC_ALL=C
# Connect to unresolvable host names
# E.g. home routers
Host router fixed-ip
HostName 192.168.50.1
User root
# Enable connections to old SSH server versions
# E.g. legacy targets using old key algorithms
Host legacy-hosts azure-vm-* oci-bastion-*
HostKeyAlgorithms +ssh-dss +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
# Avoid nuisances with ephemeral hosts and localhost
# E.g. preemptible or testing virtual machines which are often recreated
Host localhost *-vm-*
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
# User-specific settings
# E.g. programmatic accesses
Match user robots
AddKeysToAgent no
BatchMode yes
ForwardAgent no
IdentitiesOnly yes
IdentityFile ~/.ssh/robots.id_ed25519
ServerAliveCountMax 1
ServerAliveInterval 30
UseKeyChain no
# Keep connections open for some time to reuse them
# %C returns a hash of different information and is useful as socket identifier
ControlMaster auto
ControlPersist 30s
ControlPath ~/.ssh/control-%C
# User defaults
AddKeysToAgent yes
Compression yes
ForwardAgent yes
HashKnownHosts no
ServerAliveCountMax 2
ServerAliveInterval 300
UseKeyChain yes

123
examples/ssh/sshd_config Normal file
View File

@@ -0,0 +1,123 @@
# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/lib/ssh/sftp-server
# This enables accepting locale enviroment variables LC_* LANG, see sshd_config(5).
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server