Myssh: make ssh not slurp stdin.
This commit is contained in:
parent
cb040df48b
commit
69419a8f9c
1 changed files with 7 additions and 7 deletions
14
script/myssh
14
script/myssh
|
@ -34,7 +34,7 @@ get_template_string() {
|
|||
}
|
||||
|
||||
ssh_status() {
|
||||
ssh -O check -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" > /dev/null 2>&1
|
||||
ssh -n -O check -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
connect() {
|
||||
|
@ -43,14 +43,14 @@ connect() {
|
|||
if ! ssh_status
|
||||
then
|
||||
echo "" > "${CONNECTION_CACHE}"
|
||||
ssh -o "ControlPersist=10m" -M -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" q
|
||||
ssh -n -o "ControlPersist=10m" -M -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" q
|
||||
fi
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
if ssh_status
|
||||
then
|
||||
ssh -O stop -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" q
|
||||
ssh -n -O stop -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" q
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -64,15 +64,15 @@ port_forward() {
|
|||
then
|
||||
if [ -n "${ACTIVE_HOST}" ]
|
||||
then
|
||||
ssh -O cancel -L "6033:${ACTIVE_HOST}" -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" q
|
||||
ssh -n -O cancel -L "6033:${ACTIVE_HOST}" -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" q
|
||||
fi
|
||||
ssh -O forward -L "6033:$1:$2" -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}"
|
||||
ssh -n -O forward -L "6033:$1:$2" -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}"
|
||||
fi
|
||||
echo "$1:$2" > "${CONNECTION_CACHE}"
|
||||
}
|
||||
|
||||
ls_hosts() {
|
||||
ssh -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" ls
|
||||
ssh -n -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" ls
|
||||
}
|
||||
|
||||
get_host() {
|
||||
|
@ -81,7 +81,7 @@ get_host() {
|
|||
printf 'Please specify the host to connect to.\nRun "myssh ls" to list all available hosts.\n'
|
||||
exit 1
|
||||
else
|
||||
TARGET_HOST_DATA=$(ssh -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" "get $1")
|
||||
TARGET_HOST_DATA=$(ssh -n -S "${HOME}/.ssh/controlmasters/%r@%h:%p" "${SSH_SQL_PROXY_HOST}" "get $1")
|
||||
if [ "${TARGET_HOST_DATA}" = '' ]
|
||||
then
|
||||
printf 'No such host: "%s"\n' "$1"
|
||||
|
|
Loading…
Reference in a new issue