0

At the moment, I have two remotes on my git repos, one pointing to git when I am at home, and one pointing to git-ext when I am away. It want to simplify this. The below ssh config works with both git and git-ext (note the match statement is commented out). If I uncomment the match block, from what I can tell, there is no change in the behavior of the git block. When I am home, it works, when I am away, it does not.

It goes not matter if I use exec or !exec. Nothing seemingly changes. I am not sure what if happening, but I would have to say that the exec is not actually running. Any help would be appreciated.

This is running from windows WSL2, Debian 11, OpenSSH_8.4p1, Though I did try on my linux laptop running Debian 12 also, with the same results.

host git
  hostname 192.168.1.10
  user git
  identityfile ~/.ssh/id_rsa_git

#match host git !exec "/usr/bin/ping -c1 192.168.1.1"
#  proxyjump  bastion

host example.com
  hostname example.com
  user user
  identityfile ~/.ssh/id_rsa_cloud

host bastion
  hostname 192.168.1.5
  user jump
  identityfile ~/.ssh/id_rsa_bastion
  proxyjump  example.com

host git-ext
  hostname 192.168.1.10
  user git
  identityfile ~/.ssh/id_rsa_git
  proxyjump  bastion
2
  • 192.168.*.* addresses aren't reserved. Any network you connect to might use that address range and have a device responding to 192.168.1.1. You could try setting your home network to use a less commonly used block, like 192.168.42.* for example. Commented Nov 4, 2024 at 21:31
  • The ip addresses and hostnames are not real information. This is only to demonstrate the core issue. I don't want to leak my real network details on the internet. Commented Nov 5, 2024 at 3:22

1 Answer 1

1

I found the issue.

Here, I am using "git" as an alias 192.168.1.10 in the config file itself. The "host" on the match line refers to the actual host the ssh process will connect to, in the case 192.168.1.10. So after I changed git to 192.168.1.10, I could finally see the ping being executed when using verbose mode. I needed to change like this:

host git
  hostname 192.168.1.10
  user git
  identityfile ~/.ssh/id_rsa_git

match host 192.168.1.10 !exec "/usr/bin/ping -c1 192.168.1.1"
  proxyjump  bastion

host example.com
  hostname example.com
  user user
  identityfile ~/.ssh/id_rsa_cloud

host bastion
  hostname 192.168.1.5
  user jump
  identityfile ~/.ssh/id_rsa_bastion
  proxyjump  example.com

host git-ext
  hostname 192.168.1.10
  user git
  identityfile ~/.ssh/id_rsa_git
  proxyjump  bastion

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.