I am looking for a solution to my use case: I moved my SSH daemon to non-default port and would like to keep all the script kiddies connecting to my SSH via port 22 in the ssh pit (purely just for clarity of logs and to spice their life up, not as security measure).
However, I have come across some git clients that do not allow me to specify ssh port. Other than forgoing ssh operations for git in favor of using solely the git protocol on port 9418, I would like to redirect/reverse proxy client matching specific rule (user=git OR pubkey_auth=true)
- Is forwarding such ssh requests even possible without having to man-in-the-middle the connection between client and SSH daemon?
- Is the information about user or auth method visible to observer before handshakes complete and connection is established?
- Even if I had to have the service mitm the connection, and then make another encrypted tunnel between itself and local service, what kind of service should I be looking for? SSH tunnel, reverse proxy, ssh multiplexing?
I have scoured some resources, mainly splitting the traffic using IPTABLES, reverse ssh tunnel or sshpiper, but I couldn't find a way to make them filter ssh traffic for defined clients only, regardless of their IP of origin (although sshpiper looks promising and I study it further).
Note that I am perfectly fine SSHing to the server on port 2222 for other traffic, or even having the tarpit port exposed to internet, I'm just trying to account for default behaviour of some git clients.
(graphical visualisation below)
INTERNET
│
│
│
│
SSH to │port 22
│
▼
┌───────────────────┐ If user matches, ┌────────────────────────┐
│ │ forward the connection │ │
│ [email protected] ├────────────────────────► SSH Daemon Port 2222 │
│ │ │ │
└─────────┬─────────┘ └────────────────────────┘
│
┌─────────▼─────────┐ Send everyone else ┌────────────────────────┐
│ │ to the SSH tarpit │ │
│ *@example.com ├────────────────────────► EndleSSH @ Port 2022 │
│ │ │ │
└───────────────────┘ └────────────────────────┘
sshunder the hood, so/etc/ssh/ssh_configand~/.ssh/configwork and you can name hosts and specify the address and the port for each host there. Don't these clients usesshlike this?