X11 Forwarding Not Working – Troubleshooting Guide

sshterminalx11

I installed the latest version of XQuartz and:

  • changed # X11Forwarding no to X11Forwarding yes in /private/etc/ssh/sshd_config
  • enabled Allow connections from network clients in XQuartz

When I try to connect to another server via ssh -X /Users/username/.ssh/id_ed25519 username@host
in xterm, I get the following error:

ssh: Could not resolve hostname /users/username/.ssh/id_ed25519: nodename nor servname provided, or not known

I ran ssh -X remote.Unix.system xclock and the clock was shown, yet I still got the error. How can I fix this?

System:

  • MacBook Pro 2018
  • macOS Big Sur 11.5.1

Best Answer

When I try to connect to another server via ssh -X /Users/username/.ssh/id_ed25519 username@host in xterm I get the following error

If you wish to specify the private key to use, you need to provide the -i option:

ssh -X -i /Users/username/.ssh/id_ed25519 username@host

Otherwise ssh will interpret the path to your private key as the name of the server you are trying to connect to, and will fail with the error message nodename nor servname provided, or not known.

Related Question