improve linux-ssh-operator-skill: bug fixes, rsync support, tunneling docs
- Fix dry-run bug in ssh_alias_setup.sh (pub key check skipped when key was never generated) - Remove dead code in ssh_run.sh (-- check after host arg was never reachable) - Add --rsync/--delete flags to ssh_copy.sh for incremental rsync transfers - Add -C/--compress flag to ssh_run.sh for slow-link connections - Expand SKILL.md/SKILL.zh-CN.md: tunneling, jump host, SSH multiplexing, Docker ops - Expand ssh-playbook.md: port forwarding, bastion, ControlMaster, structured troubleshooting table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ Options:
|
||||
-p, --port PORT SSH port (default: REMOTE_PORT or 22)
|
||||
-i, --key PATH Identity file (default: REMOTE_KEY)
|
||||
-t, --tty Force pseudo-tty allocation (useful for sudo prompts)
|
||||
-C, --compress Enable SSH compression (useful on slow links)
|
||||
--accept-new Set StrictHostKeyChecking=accept-new
|
||||
--sudo Prefix command with sudo --
|
||||
--sudo-non-interactive Prefix command with sudo -n -- (fails if password needed)
|
||||
@@ -36,6 +37,7 @@ key="${REMOTE_KEY:-}"
|
||||
connect_timeout="${REMOTE_CONNECT_TIMEOUT:-10}"
|
||||
|
||||
tty=false
|
||||
compress=false
|
||||
accept_new=false
|
||||
sudo_mode=""
|
||||
dry_run=false
|
||||
@@ -58,6 +60,10 @@ while [[ $# -gt 0 ]]; do
|
||||
tty=true
|
||||
shift
|
||||
;;
|
||||
-C|--compress)
|
||||
compress=true
|
||||
shift
|
||||
;;
|
||||
--accept-new)
|
||||
accept_new=true
|
||||
shift
|
||||
@@ -126,14 +132,15 @@ if $accept_new; then
|
||||
ssh_opts+=(-o "StrictHostKeyChecking=accept-new")
|
||||
fi
|
||||
|
||||
if $compress; then
|
||||
ssh_opts+=(-C)
|
||||
fi
|
||||
|
||||
if $tty; then
|
||||
ssh_opts+=(-tt)
|
||||
fi
|
||||
|
||||
cmd=("$@")
|
||||
if [[ ${#cmd[@]} -gt 0 && "${cmd[0]}" == "--" ]]; then
|
||||
cmd=("${cmd[@]:1}")
|
||||
fi
|
||||
if [[ -n "$sudo_mode" && ${#cmd[@]} -gt 0 ]]; then
|
||||
if [[ "$sudo_mode" == "sudo-n" ]]; then
|
||||
cmd=("sudo" "-n" "--" "${cmd[@]}")
|
||||
|
||||
Reference in New Issue
Block a user