Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Security and hardening

ssh jump host fails on Windows because nc is not installed

Error/usr/bin/bash: line 0: exec: nc: not found

Short answer

ProxyCommand runs the command you wrote through your shell, so nc has to exist on that machine. Git for Windows does not ship it. Replace the nc line with ProxyJump, or with ProxyCommand ssh -W %h:%p jumphost. Both let the OpenSSH client open the tunnel by itself, so no netcat is needed.

  • Applies to OpenSSH client 9.x, Windows 11, Git for Windows 2.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the ProxyCommand ssh really uses for the host. It shows which helper program the config asks for.

    ssh -G target | grep -i -E "^(proxycommand|proxyjump)"
  2. 2Match what you see, then jump to its fix

    1. 1exec: nc: not foundThe config calls nc, which is not installedFix
    2. 2an older config or tutorial line such as ProxyCommand nc %h %pYou need ProxyCommand (for example to pass extra options) but want no netcatFix
    3. 3ProxyJump seems ignored and the nc error remainsBoth ProxyCommand and ProxyJump are set, and the first one winsFix

What does the error look like?

  • /usr/bin/bash: line 0: exec: nc: not found

Cause 1 of 3

The config calls nc, which is not installed

1Check

ProxyCommand is run with the shell's exec directive, so the program in it must be found on PATH. Ask the shell whether nc exists.

command -v nc || echo "nc is missing"
grep -n -i "ProxyCommand" ~/.ssh/config

2Fix

Stop depending on nc. Describe the jump host with ProxyJump; ssh then opens the hop itself.

# ~/.ssh/config
Host target
    HostName 10.0.0.20
    User deploy
    ProxyJump jumpuser@jump.example.com

3Verify

Connect to the target; ssh should ask for the target's login, not print the nc error.

ssh -v target

Confirmed by man.openbsd.org

Did this fix it?

Cause 2 of 3

You need ProxyCommand (for example to pass extra options) but want no netcat

1Check

ProxyCommand and ProxyJump both accept the %h and %p tokens. ssh itself can forward standard input and output to a host and port with -W, so a second ssh can replace nc.

grep -n "%h" ~/.ssh/config

2Fix

Point ProxyCommand at ssh -W instead of nc.

# ~/.ssh/config
Host target
    HostName 10.0.0.20
    ProxyCommand ssh -W %h:%p jumpuser@jump.example.com

3Verify

Run a command through the tunnel.

ssh target hostname

Confirmed by man.openbsd.org

Did this fix it?

Cause 3 of 3

Both ProxyCommand and ProxyJump are set, and the first one wins

1Check

ssh_config says the two options conflict and the one specified first takes effect, so an old ProxyCommand earlier in the file (or under Host *) hides your new ProxyJump.

ssh -G target | grep -i -E "^(proxycommand|proxyjump)"

2Fix

Delete the old ProxyCommand line, or set ProxyCommand none for this host before the ProxyJump line.

Host target
    ProxyCommand none
    ProxyJump jumpuser@jump.example.com

3Verify

The effective config should now list only the jump.

ssh -G target | grep -i proxy

Confirmed by man.openbsd.org

Did this fix it?

How do I stop it coming back?

  • Prefer ProxyJump (or ssh -J) for plain SSH hops; keep ProxyCommand for real proxies.
  • Keep jump host settings such as user and key in ~/.ssh/config, as the OpenSSH manual advises.
  • Use ssh -G host to see the final merged config before debugging connections.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.