← retour aux snippets

ssh config: Match et ProxyJump utiles

Configurer des hôtes avec Match par address/user et chaîner via ProxyJump simplement.

bash network #ssh#proxyjump#config

objectif

Simplifier des accès complexes via bastions et appliquer des réglages conditionnels.

code minimal

# ~/.ssh/config
Host bastion
  HostName bastion.data.pm
  User ops

Host app-*
  User deploy
  IdentityFile ~/.ssh/id_ed25519
  ProxyJump bastion

Match host "app-*" exec "test %r = deploy"
  ServerAliveInterval 30
  ServerAliveCountMax 3

utilisation

ssh app-01

variante(s) utile(s)

# ProxyCommand (fallback ancien OpenSSH)
Host app-*
  ProxyCommand ssh -W %h:%p bastion

notes

  • ProxyJump simplifie le chaînage; Match permet des règles ciblées.
  • combinez avec ControlMaster/ControlPersist (voir snippet multiplexage SSH).