]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/ssh_config
69bc19742954248f6ad75a9f0087bd4add32dd9a
[config/dotfiles.git] / shell / ssh_config
1 # SSH configuration file.
2 #
3 # Some options are set even if they are default to prevent /etc/ssh/ssh_config
4 # from overwriting them.
5
6 # Copyright (C) 2011-2020  Simon Ruderich
7 #
8 # This file is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this file.  If not, see <http://www.gnu.org/licenses/>.
20
21 # Undocumented (and not very well tested) feature. This drops the connection
22 # after 5 seconds of inactivity. Thanks to shad0VV in #openssh on Freenode
23 # (2012-11-04 18:40 CET) for telling me about this undocumented feature.
24 #
25 #     ServerAliveCountMax 0
26 #     ServerAliveInterval 5
27
28
29 # Options are parsed top-to-bottom, the first matching option is used. Later
30 # assignments to the same option are ignored, thanks to anonJD in #openssh on
31 # Freenode (2011-05-18 21:40 CEST) for letting me know. Therefore put all
32 # affected host specific rules here, before the global rules.
33 #
34 # For example to change the MACs option for a specific host, use:
35 #
36 # Host host
37 #     # Old SSH daemon which needs SHA1 (SHA-512 in case it gets updated).
38 #     MACs hmac-sha2-512,hmac-sha1
39
40
41 # Rules for all hosts.
42 Host *
43
44 # Force protocol version 2 which is more secure (default).
45     Protocol 2
46
47 # Use stronger algorithms. If some hosts require weaker versions then use Host
48 # groups to enable them only for those specific machines.
49
50 # Don't use SHA1 and disable elliptic curves whose security regarding the
51 # parameters is still in debate.
52     KexAlgorithms diffie-hellman-group16-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group18-sha512
53 # Use stronger cipher versions. Disable CBC ciphers to prevent (unlikely)
54 # plaintext recovery attack [1], disable RC4 because it's broken [2]; this
55 # leaves only AES. No GCM ciphers yet because they are still very new.
56 #
57 # [1]: http://www.openssh.com/txt/cbc.adv
58 # [2]: http://www.schneier.com/blog/archives/2013/03/new_rc4_attack.html
59     Ciphers aes256-ctr
60 # Don't use weak MACs like MD5 or SHA1. However strong MACs are not as
61 # important as strong ciphers because an attacker must be able to break a MAC
62 # in real time to modify the data in transmit. Prefer "-etm" algorithms which
63 # use encrypt-then-mac which is more secure than the default encrypt-and-mac
64 # in SSH [1] (available since 6.2).
65 #
66 # [1]: http://cseweb.ucsd.edu/~mihir/papers/oem.html
67     MACs hmac-sha2-512-etm@openssh.com
68 # Disable ssh-rsa which is vulnerable to recent chosen prefix attacks against
69 # SHA1 [1][2]. Disable elliptic curves whose security regarding the parameters
70 # is still in debate. I don't need certificates, therefore disable those
71 # algorithms as well (*-cert-*).
72 #
73 # [1]: https://www.openssh.com/txt/release-8.2
74 # [2]: "SHA-1 is a Shambles: First Chosen-Prefix Collision on SHA-1 and
75 #      Application to the PGP Web of Trust" Leurent, G and Peyrin, T (2020)
76 #      https://eprint.iacr.org/2020/014.pdf
77     HostKeyAlgorithms rsa-sha2-512
78 # Also disable weak algorithms for public key authentication. Use a blacklist
79 # because multiple algorithms might be already in use.
80     PubkeyAcceptedKeyTypes -ssh-rsa,ssh-rsa-cert-v01@openssh.com,ssh-dss,ssh-dss-cert-v01@openssh.com
81
82 # Disable X11 and agent forwarding for security reasons (defaults).
83     ForwardX11 no
84     ForwardAgent no
85 # Don't trust remote X11 clients. If enabled allows bad admins complete access
86 # to local X11!
87     ForwardX11Trusted no
88
89 # Disable authentication methods I don't use.
90     ChallengeResponseAuthentication no
91     GSSAPIAuthentication no
92     HostbasedAuthentication no
93     KbdInteractiveAuthentication no
94 # Only enable those I need.
95     PasswordAuthentication yes
96     PubkeyAuthentication yes
97
98 # Use only authentication identity files configured in ~/.ssh/config even if
99 # ssh-agent offers more identities.
100     IdentitiesOnly yes
101
102 # Bind local forwardings to loopback only. This way no remote hosts can access
103 # them (default).
104     GatewayPorts no
105 # Abort if not all requested port forwardings can be set up.
106     ExitOnForwardFailure yes
107
108 # Allow using -M (ControlMaster) to create a master SSH session which
109 # "tunnels" other connections to the same host, thus reducing the number of
110 # authentications (which are relatively slow) and TCP connections. The master
111 # sockets are stored in ~/.ssh (by default ControlPath is not set). Using %r
112 # (remote user name) might leak information to other users on the current
113 # system (e.g. via netstat or lsof).
114     ControlPath ~/.ssh/master/%l-%h-%p-%r
115 # Automatically create a new master session if there's none yet or use an
116 # existing one. This way the user doesn't have to use -M to enable a master
117 # manually. Don't set this option to "yes" or all SSH commands try to become
118 # the master session which is obviously not possible.
119     ControlMaster auto
120 # When the connection for a master is closed (e.g. logout of remote shell),
121 # move the master connection in the background. If there's no other active
122 # connection using the master, close it after x seconds. This prevents the
123 # client of the master connection from blocking because it waits for all
124 # connections using it to terminate which is very annoying. The timeout
125 # prevents stale master connections.
126     ControlPersist 10
127
128 # Don't permit running local commands (default).
129     PermitLocalCommand no
130
131 # Don't send any environment variables (default).
132     SendEnv
133
134 # Don't hash any hosts in ~/.ssh/known_hosts. It doesn't help if the ssh hosts
135 # are stored in the shell's history file or in this file as shortcut so it's
136 # rather useless (default).
137     HashKnownHosts no
138
139 # Check host IP in known_hosts when connecting to detect DNS spoofing
140 # (default).
141     CheckHostIP yes
142 # Ask before adding any host keys to ~/.ssh/known_hosts (default).
143     StrictHostKeyChecking ask
144 # Check host keys from DNS' SSHFP resource records but ask apply
145 # StrictHostKeyChecking before trusting them.
146     VerifyHostKeyDNS ask