Unexpected SSH failures with ForwardAgent enabled

10 views
Skip to first unread message

rob...@gmail.com

unread,
Apr 22, 2024, 12:46:50 PM4/22/24
to Rex Users
I am posting this here as I've gotten hit with this problem and then hit again a few years later when I've forgotten the cause.

I've run into some strange issues where .ssh/config is set up for a server with ForwardAgent enabled, so you can run

  ssh -A server "ssh -T g...@github.com"

and it works, as does

  ssh -A server "cd /path && git pull origin main"

But when I ran that git pull command through Rex (using the SCM checkout command), I get a "Permission denied (publickey)" from github.

The problem was caused by the .ssh/config for that server:

Host server
  Hostname 1.2.3.4
  IdentityFile ~/.ssh/server-private-key
  ForwardAgent yes

The "Hostname" directive seems to have kept the IP address from being added to the .ssh/known_hosts file. Somehow the trust for the Hostname is not passed through to git when run in Rex.

Removing the "Hostname" (and adding the server to /etc/hosts if necessary),  and reconnecting to the server to update known_hosts fixed the issue.









Reply all
Reply to author
Forward
0 new messages