fixed ssh func bug where remote command was before host
this fixed issue with remote script modulemaster
parent
c857bb50be
commit
3ffbd545fe
|
@ -177,7 +177,7 @@ EOF
|
||||||
# sshcp -y -d $host $bscript $rscript -- "${sshargs[@]}"
|
# sshcp -y -d $host $bscript $rscript -- "${sshargs[@]}"
|
||||||
# return
|
# return
|
||||||
if sshcp -d $host $bscript $rscript -- "${sshargs[@]}"; then
|
if sshcp -d $host $bscript $rscript -- "${sshargs[@]}"; then
|
||||||
# make remote script excuteable
|
# echo make remote script excuteable
|
||||||
ssh "${sshargs[@]}" "$host" "chmod +x $rscript"
|
ssh "${sshargs[@]}" "$host" "chmod +x $rscript"
|
||||||
ssh "${sshargs[@]}" "$host" "$usesudo" "$env_vars" "$shell" $login "$rscript" "$(escape_args "$@")"
|
ssh "${sshargs[@]}" "$host" "$usesudo" "$env_vars" "$shell" $login "$rscript" "$(escape_args "$@")"
|
||||||
# now delete it, save script if passed an explicit name
|
# now delete it, save script if passed an explicit name
|
||||||
|
|
|
@ -81,7 +81,6 @@ sshpubkey () {
|
||||||
usage: sshpubkey <pubkey opts> host <ssh script options>
|
usage: sshpubkey <pubkey opts> host <ssh script options>
|
||||||
-a, <alternate user> put the key at another user on remote. if you want to put it to root use 'root' will require remote sudo
|
-a, <alternate user> put the key at another user on remote. if you want to put it to root use 'root' will require remote sudo
|
||||||
-u, <user> remote user if not available in host
|
-u, <user> remote user if not available in host
|
||||||
-s, <paswd> sudo password for remote if needed
|
|
||||||
-k, <key> can be either the path to a public key file or the name of the key currently loaded in an ssh agent
|
-k, <key> can be either the path to a public key file or the name of the key currently loaded in an ssh agent
|
||||||
-l, list the keys for the remote user
|
-l, list the keys for the remote user
|
||||||
-r, remove the key from the user, use the comment identifier of the public key
|
-r, remove the key from the user, use the comment identifier of the public key
|
||||||
|
|
|
@ -30,9 +30,9 @@ ssh() {
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage:
|
usage:
|
||||||
ssh <script options> host <SSH command options> <commands to run on remote>
|
ssh <script options> host <commands to run on remote>
|
||||||
put any additional SSH (man ssh) options after the host, aborting
|
put any additional SSH (man ssh) options can be added with -s, be sure to quote
|
||||||
hH:tu:dF:p:ro:k:
|
:hH:tu:dF:p:ro:k:
|
||||||
-h
|
-h
|
||||||
-H
|
-H
|
||||||
-t
|
-t
|
||||||
|
@ -41,23 +41,23 @@ hH:tu:dF:p:ro:k:
|
||||||
-F
|
-F
|
||||||
-p
|
-p
|
||||||
-r
|
-r
|
||||||
|
-s
|
||||||
-o
|
-o
|
||||||
-k
|
-k-z no
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [[ $SSH_CONFIG ]]; then
|
if [[ $SSH_CONFIG ]]; then
|
||||||
[[ ! -f "$SSH_CONFIG" ]] && ssh_config "$SSH_CONFIG"
|
[[ ! -f "$SSH_CONFIG" ]] && ssh_config "$SSH_CONFIG"
|
||||||
cfg="-F $SSH_CONFIG"
|
cfg="-F $SSH_CONFIG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# echo passed: $*
|
|
||||||
|
|
||||||
local OPTION; local OPTARG; local OPTIND
|
local OPTION; local OPTARG; local OPTIND
|
||||||
while getopts 'hH:th:u:lF:p:ro:k:' OPTION; do
|
while getopts 'hH:th:u:lF:p:ro:k:' OPTION; do
|
||||||
# echo processing: option:$OPTION argument:$OPTARG index:$OPTIND remaining:${@:$OPTIND}
|
# echo ssh passed: "$@"
|
||||||
|
debug processing: option:$OPTION argument:$OPTARG index:$OPTIND
|
||||||
|
# echo remaining:${@:$OPTIND}
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
h)
|
h)
|
||||||
help
|
help
|
||||||
|
@ -86,7 +86,7 @@ EOF
|
||||||
opts+=" -o $OPTARG"
|
opts+=" -o $OPTARG"
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
# pw=$OPTARG
|
# pw=$OPTARGF
|
||||||
#e, f, d
|
#e, f, d
|
||||||
case "$OPTARG" in
|
case "$OPTARG" in
|
||||||
e)
|
e)
|
||||||
|
@ -114,7 +114,7 @@ EOF
|
||||||
# mp=true
|
# mp=true
|
||||||
# ;;
|
# ;;
|
||||||
*)
|
*)
|
||||||
echo unknown script option $OPTARG
|
echo unknown ssh script option $OPTARG xxx
|
||||||
help
|
help
|
||||||
return 3
|
return 3
|
||||||
# opts+=" ${@:$OPTIND:1}"
|
# opts+=" ${@:$OPTIND:1}"
|
||||||
|
@ -128,7 +128,8 @@ EOF
|
||||||
|
|
||||||
[[ (! $host) && $1 ]] && { host=$1;shift; }
|
[[ (! $host) && $1 ]] && { host=$1;shift; }
|
||||||
|
|
||||||
debug extra ssh options and the remote commands: $@
|
debug remote commands/arguments to pass: $@
|
||||||
|
debug todo parse additional options after --
|
||||||
|
|
||||||
[[ ! $host && ! $list ]] && echo host/ip required, aborting && return 2
|
[[ ! $host && ! $list ]] && echo host/ip required, aborting && return 2
|
||||||
if [[ $host ]]; then
|
if [[ $host ]]; then
|
||||||
|
@ -146,11 +147,11 @@ if [[ $ret ]]; then
|
||||||
# return arguments so a command can be composed elsewhere
|
# return arguments so a command can be composed elsewhere
|
||||||
{ echo "$host,$opts $* ,$sshpass"; return 0; }
|
{ echo "$host,$opts $* ,$sshpass"; return 0; }
|
||||||
else
|
else
|
||||||
sshcmd="$sshpass $(which ssh) $term $opts $host"
|
sshcmd="$sshpass $(which ssh) $term $opts $host $*"
|
||||||
if [[ $list ]]; then
|
if [[ $list ]]; then
|
||||||
echo $sshcmd
|
echo "$sshcmd"
|
||||||
else
|
else
|
||||||
$sshcmd "$@" || echo SSH Command Failed: $sshcmd "$@"
|
$sshcmd || echo SSH Command Failed: $sshcmd
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue