Skip to content

Commit b3fa2b4

Browse files
[CF1] sshd_config troubleshooting
1 parent 8c837e7 commit b3fa2b4

File tree

1 file changed

+190
-1
lines changed

1 file changed

+190
-1
lines changed

src/content/docs/cloudflare-one/connections/connect-networks/use-cases/ssh/ssh-infrastructure-access.mdx

Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
label: SSH with Access for Infrastructure
77
---
88

9-
import { Tabs, TabItem, Badge, Render, APIRequest } from "~/components";
9+
import { Tabs, TabItem, Badge, Render, APIRequest, Steps } from "~/components";
1010

1111
[Access for Infrastructure](/cloudflare-one/applications/non-http/infrastructure-apps/) provides granular control over how users can connect to your SSH servers. This feature uses the same deployment model as [WARP-to-Tunnel](/cloudflare-one/connections/connect-networks/use-cases/ssh/ssh-warp-to-tunnel/) but unlocks more policy options and command logging functionality.
1212

@@ -188,3 +188,192 @@ The following SSH features are not supported:
188188
### Session duration
189189

190190
SSH sessions have a maximum expected duration of 10 hours. For more information, refer to the [Troubleshooting FAQ](/cloudflare-one/faq/troubleshooting/#long-lived-ssh-sessions-frequently-disconnect).
191+
192+
## Troubleshooting
193+
194+
### `sshd_config` file misconfiguration
195+
196+
Failure to connect to your SSH endpoint could be the result of multiple variables. One reason might be the result of a misconfigured `sshd_config` file.
197+
198+
#### Review your `sshd_config` file for misconfigurations
199+
200+
To rule out any issues in your `sshd_config` file, compare your existing `sshd_config` file with the example below to verify if any directives are causing authentication issues. The following example `sshd_config` file will result in successful authentication:
201+
202+
<details>
203+
<summary>Example `sshd_config` file</summary>
204+
205+
```
206+
# This is the sshd server system-wide configuration file. See
207+
# sshd_config(5) for more information.
208+
209+
# The strategy used for options in the default sshd_config shipped with
210+
# OpenSSH is to specify options with their default value where
211+
# possible, but leave them commented. Uncommented options override the
212+
# default value.
213+
214+
PubkeyAuthentication yes
215+
TrustedUserCAKeys /etc/ssh/ca.pub
216+
217+
Include /etc/ssh/sshd_config.d/*.conf
218+
219+
# When systemd socket activation is used (the default), the socket
220+
# configuration must be re-generated after changing Port, AddressFamily, or
221+
# ListenAddress.
222+
#
223+
# For changes to take effect, run:
224+
#
225+
# systemctl daemon-reload
226+
# systemctl restart ssh.socket
227+
#
228+
#Port 22
229+
#AddressFamily any
230+
#ListenAddress 0.0.0.0
231+
#ListenAddress ::
232+
233+
#HostKey /etc/ssh/ssh_host_rsa_key
234+
#HostKey /etc/ssh/ssh_host_ecdsa_key
235+
#HostKey /etc/ssh/ssh_host_ed25519_key
236+
237+
# Ciphers and keying
238+
#RekeyLimit default none
239+
240+
# Logging
241+
#SyslogFacility AUTH
242+
LogLevel DEBUG3
243+
244+
# Authentication:
245+
246+
#LoginGraceTime 2m
247+
PermitRootLogin yes
248+
#StrictModes yes
249+
#MaxAuthTries 6
250+
#MaxSessions 10
251+
252+
253+
254+
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
255+
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
256+
257+
#AuthorizedPrincipalsFile none
258+
259+
#AuthorizedKeysCommand none
260+
#AuthorizedKeysCommandUser nobody
261+
262+
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
263+
#HostbasedAuthentication no
264+
# Change to yes if you don't trust ~/.ssh/known_hosts for
265+
# HostbasedAuthentication
266+
#IgnoreUserKnownHosts no
267+
# Don't read the user's ~/.rhosts and ~/.shosts files
268+
#IgnoreRhosts yes
269+
270+
# To disable tunneled clear text passwords, change to no here!
271+
#PasswordAuthentication yes
272+
#PermitEmptyPasswords no
273+
274+
# Change to yes to enable challenge-response passwords (beware issues with
275+
# some PAM modules and threads)
276+
KbdInteractiveAuthentication no
277+
278+
# Kerberos options
279+
#KerberosAuthentication no
280+
#KerberosOrLocalPasswd yes
281+
#KerberosTicketCleanup yes
282+
#KerberosGetAFSToken no
283+
284+
# GSSAPI options
285+
#GSSAPIAuthentication no
286+
#GSSAPICleanupCredentials yes
287+
#GSSAPIStrictAcceptorCheck yes
288+
#GSSAPIKeyExchange no
289+
290+
# Set this to 'yes' to enable PAM authentication, account processing,
291+
# and session processing. If this is enabled, PAM authentication will
292+
# be allowed through the KbdInteractiveAuthentication and
293+
# PasswordAuthentication. Depending on your PAM configuration,
294+
# PAM authentication via KbdInteractiveAuthentication may bypass
295+
# the setting of "PermitRootLogin yes
296+
# If you just want the PAM account and session checks to run without
297+
# PAM authentication, then enable this but set PasswordAuthentication
298+
# and KbdInteractiveAuthentication to 'no'.
299+
UsePAM yes
300+
301+
#AllowAgentForwarding yes
302+
#AllowTcpForwarding yes
303+
#GatewayPorts no
304+
X11Forwarding yes
305+
#X11DisplayOffset 10
306+
#X11UseLocalhost yes
307+
#PermitTTY yes
308+
PrintMotd no
309+
#PrintLastLog yes
310+
#TCPKeepAlive yes
311+
#PermitUserEnvironment no
312+
#Compression delayed
313+
#ClientAliveInterval 0
314+
#ClientAliveCountMax 3
315+
#UseDNS no
316+
#PidFile /run/sshd.pid
317+
#MaxStartups 10:30:100
318+
#PermitTunnel no
319+
#ChrootDirectory none
320+
#VersionAddendum none
321+
322+
# no default banner path
323+
#Banner none
324+
325+
# Allow client to pass locale environment variables
326+
AcceptEnv LANG LC_*
327+
328+
# override default of no subsystems
329+
Subsystem sftp /usr/lib/openssh/sftp-server
330+
331+
# Example of overriding settings on a per-user basis
332+
#Match User anoncvs
333+
# X11Forwarding no
334+
# AllowTcpForwarding no
335+
# PermitTTY no
336+
# ForceCommand cvs server
337+
```
338+
339+
</details>
340+
341+
#### Replace and test with example configuration
342+
343+
The next steps will walk you through a troubleshooting regimen. You will temporarily replace your existing `sshd_config` file with the provided example to rule out configuration issues. Before proceeding, carefully [review and compare both files](#review-your-sshd_config-file-for-misconfigurations) to identify any conflicting directives.
344+
345+
:::caution[You may be lose access to your SSH server]
346+
347+
These troubleshooting steps could result in you being locked out of your SSH server because your existing auth may rely on existing configuration that is not in the [example file](#review-your-sshd_config-file-for-misconfigurations). Proceed with utmost caution.
348+
349+
:::
350+
351+
1. Back up the existing `sshd_config` file.
352+
353+
```
354+
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
355+
```
356+
357+
2. Create a new `sshd_config` file.
358+
359+
```
360+
vi /etc/ssh/sshd_config
361+
```
362+
363+
3. Enter insert mode by pressing the 'i' character on your keyboard.
364+
365+
4. Paste in the [example file](#review-your-sshd_config-file-for-misconfigurations).
366+
367+
5. Exit insert mode by pressing the escape `esc` key.
368+
6. Enter `:x` to save and exit.
369+
7. [Reload](#reload-your-ssh-server) your SSH server.
370+
371+
:::caution[You may lose access to your SSH server]
372+
Restarting your `sshd` service will result in the termination of your current SSH connection. Make sure your reload instead restarting to avoid losing access to your SSH server permanently.
373+
:::
374+
375+
<Render file="ssh/restart-server" product="cloudflare-one" />
376+
377+
378+
379+

0 commit comments

Comments
 (0)