feat: support jump host ports in SSH menu
Allow jump host definitions to include an explicit port in the form user@host:port. Default to port 22 when no port is provided and update the sample config and docs accordingly.
This commit is contained in:
@@ -9,6 +9,5 @@
|
|||||||
- Documentation language: English.
|
- Documentation language: English.
|
||||||
- Current task focus: keep README and memory aligned with the working script and sample configuration.
|
- Current task focus: keep README and memory aligned with the working script and sample configuration.
|
||||||
- Known follow-up improvements:
|
- Known follow-up improvements:
|
||||||
- Jump server currently does not support an alternate port; this needs to be added.
|
|
||||||
- Group naming should avoid duplicating the file name and the YAML value.
|
- Group naming should avoid duplicating the file name and the YAML value.
|
||||||
- Each group should have default values.
|
- Each group should have default values.
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ ssh:
|
|||||||
default_options: ""
|
default_options: ""
|
||||||
jump_hosts:
|
jump_hosts:
|
||||||
office: "user@192.168.10.11"
|
office: "user@192.168.10.11"
|
||||||
|
office-alt: "user@192.168.10.11:2222"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### `hosts/dev.yaml`
|
### `hosts/dev.yaml`
|
||||||
@@ -98,6 +100,7 @@ A complete sample configuration is available in `sample-config/`.
|
|||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- `jump_host` values are resolved by name from `global.yaml`.
|
- `jump_host` values are resolved by name from `global.yaml`.
|
||||||
|
- Jump hosts support `user@host` and `user@host:port`; if the port is omitted, `22` is used.
|
||||||
- If a host does not define a user or port, global defaults are used.
|
- If a host does not define a user or port, global defaults are used.
|
||||||
- `default_options` is present in the config but not consumed by the current script.
|
- `default_options` is present in the config but not consumed by the current script.
|
||||||
- The sample config includes `ssh_options` in one file, but the current script does not consume it yet.
|
- The sample config includes `ssh_options` in one file, but the current script does not consume it yet.
|
||||||
|
|||||||
+8
-1
@@ -153,7 +153,14 @@ ssh_connect() {
|
|||||||
SSH_JUMP_HOST=$(jq -r '.jump_host // ""' <<<"$SERVER")
|
SSH_JUMP_HOST=$(jq -r '.jump_host // ""' <<<"$SERVER")
|
||||||
if [ "$SSH_JUMP_HOST" != "" ]; then
|
if [ "$SSH_JUMP_HOST" != "" ]; then
|
||||||
SSH_JUMP_HOST=$(jq -r '.'"$SSH_JUMP_HOST"' // ""' <<<"${SSH_JUMP_HOSTS}")
|
SSH_JUMP_HOST=$(jq -r '.'"$SSH_JUMP_HOST"' // ""' <<<"${SSH_JUMP_HOSTS}")
|
||||||
SSH_JUMP_HOST="-t $SSH_JUMP_HOST ssh -p $SSH_SERVER_PORT"
|
SSH_JUMP_HOST_USER=$(cut -d'@' -f1 <<<"$SSH_JUMP_HOST")
|
||||||
|
SSH_JUMP_HOST_TARGET=$(cut -d'@' -f2- <<<"$SSH_JUMP_HOST")
|
||||||
|
SSH_JUMP_HOST_TARGET_HOST=$(cut -d':' -f1 <<<"$SSH_JUMP_HOST_TARGET")
|
||||||
|
SSH_JUMP_HOST_TARGET_PORT=$(cut -s -d':' -f2 <<<"$SSH_JUMP_HOST_TARGET")
|
||||||
|
if [ "$SSH_JUMP_HOST_TARGET_PORT" = "" ]; then
|
||||||
|
SSH_JUMP_HOST_TARGET_PORT="22"
|
||||||
|
fi
|
||||||
|
SSH_JUMP_HOST="-t ${SSH_JUMP_HOST_USER}@${SSH_JUMP_HOST_TARGET_HOST} ssh -p ${SSH_JUMP_HOST_TARGET_PORT}"
|
||||||
SSH_SERVER_OPTIONS=""
|
SSH_SERVER_OPTIONS=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ ssh:
|
|||||||
default_options: ""
|
default_options: ""
|
||||||
jump_hosts:
|
jump_hosts:
|
||||||
office: "user@192.168.10.11"
|
office: "user@192.168.10.11"
|
||||||
|
dev: "user@192.168.10.11:2222"
|
||||||
|
backup: "admin@10.0.0.5:2200"
|
||||||
|
|||||||
Reference in New Issue
Block a user