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_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() {
|
connect() {
|
||||||
|
@ -43,14 +43,14 @@ connect() {
|
||||||
if ! ssh_status
|
if ! ssh_status
|
||||||
then
|
then
|
||||||
echo "" > "${CONNECTION_CACHE}"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
if ssh_status
|
if ssh_status
|
||||||
then
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,15 +64,15 @@ port_forward() {
|
||||||
then
|
then
|
||||||
if [ -n "${ACTIVE_HOST}" ]
|
if [ -n "${ACTIVE_HOST}" ]
|
||||||
then
|
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
|
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
|
fi
|
||||||
echo "$1:$2" > "${CONNECTION_CACHE}"
|
echo "$1:$2" > "${CONNECTION_CACHE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
ls_hosts() {
|
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() {
|
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'
|
printf 'Please specify the host to connect to.\nRun "myssh ls" to list all available hosts.\n'
|
||||||
exit 1
|
exit 1
|
||||||
else
|
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}" = '' ]
|
if [ "${TARGET_HOST_DATA}" = '' ]
|
||||||
then
|
then
|
||||||
printf 'No such host: "%s"\n' "$1"
|
printf 'No such host: "%s"\n' "$1"
|
||||||
|
|
Loading…
Reference in a new issue