Files
xop/examples/ssh.sh
T
2026-10-02 18:25:29 +08:00

31 lines
927 B
Bash
Executable File

#!/usr/bin/env bash
# Real SSH exec — secrets stored locally, gated by Touch ID / PAM + passphrase.
#
# Before running, you must have stored the secret:
# xop init
# echo "..." | xop set SSH_PASS
#
# At spawn time, xop will:
# 1. Trigger Touch ID (macOS) or pkexec (Linux) to confirm your identity
# 2. Prompt for the vault passphrase (hidden)
# 3. Decrypt SSH_PASS from `~/.xop/key.db`
# 4. Spawn `ssh` with SSH_PASS in env (askpass strategy still P1)
#
# v0.2 currently passes the password via env var (fallback strategy).
# Askpass strategy (which avoids any trace in /proc/<pid>/environ) is P1.
set -euo pipefail
cd "$(dirname "$0")/.."
HOST="${HOST:-192.168.1.19}"
USER="${USER:-rong}"
./target/release/xop \
--secret SSH_PASS='ssh_pass' \
--allow-net="${HOST}:22" \
--deny-net='*' \
-- \
ssh -o StrictHostKeyChecking=accept-new \
-o UserKnownHostsFile=/dev/null \
"${USER}@${HOST}"