change version number and addapt the script to let me add rsp
This commit is contained in:
parent
933f1b5987
commit
830ffa53de
1 changed files with 87 additions and 16 deletions
|
@ -12,34 +12,77 @@
|
||||||
# and % will delete the parameter at the end.
|
# and % will delete the parameter at the end.
|
||||||
|
|
||||||
|
|
||||||
User="root"
|
default_user="root"
|
||||||
Port=10022
|
default_hostname="localhost"
|
||||||
Version="1.1.0"
|
default_ssh_port="22"
|
||||||
|
default_rsp_port="3389"
|
||||||
|
default_vnc_port="5900"
|
||||||
|
|
||||||
|
Version="2.0.0"
|
||||||
|
|
||||||
Help_message="
|
Help_message="
|
||||||
$(basename $0) [OPTION] [OPTION=VALUE]
|
$(basename $0) PROTOCOL [OPTION] [OPTION=VALUE]
|
||||||
|
|
||||||
script which permit to launch ssh to connect to the vm on localhost without letting any traces on this computer.
|
script which permit to launch a remote connection protocol.
|
||||||
|
|
||||||
-u <user>,--user=<user> Select the user, by default root
|
PROTOCOL available
|
||||||
-p <port>,--port=<port> Select the port, by default 10022
|
ssh A command line protocol which can be used to connect with tcp
|
||||||
|
rsp The windows remote server protocol
|
||||||
|
|
||||||
|
PROTOCOL #TODO
|
||||||
|
vnc Virtual Networking Computing, permit to have access to a graphical user interface.
|
||||||
|
|
||||||
|
OPTION available
|
||||||
-v, --version print the version and exit
|
-v, --version print the version and exit
|
||||||
-h, --help print this help and exit
|
-h, --help print this help and exit
|
||||||
|
-u <user>,--user=<user> Select the user, by default root
|
||||||
|
-p <port>,--port=<port> Select the port, by default 10022
|
||||||
-H <hostname>, --hostname=<hostname> Select the host to connect #TODO
|
-H <hostname>, --hostname=<hostname> Select the host to connect #TODO
|
||||||
-P <protocol>, --protocol=<protocol> Select the protocol to use #TODO
|
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
||||||
|
start_ssh() {
|
||||||
|
if [ "${port}" == "" ]
|
||||||
|
then
|
||||||
|
port="${default_ssh_port}"
|
||||||
|
fi
|
||||||
|
echo "start ssh"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_rsp() {
|
||||||
|
if [ "${port}" == "" ]
|
||||||
|
then
|
||||||
|
port="${default_rsp_port}"
|
||||||
|
fi
|
||||||
|
echo "start rsp"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"ssh")
|
||||||
|
protocol="ssh"
|
||||||
|
;;
|
||||||
|
"rsp")
|
||||||
|
protocol="rsp"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "protocol $1 uknown" >&2
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
# looking for double parametters.
|
# looking for double parametters.
|
||||||
|
|
||||||
for (( arg=1; arg<$#; arg++)); do
|
for (( arg=2; arg<$#; arg++)); do
|
||||||
value="$((arg+1))"
|
value="$((arg+1))"
|
||||||
if [ "${!arg}" == "-u" ]
|
if [ "${!arg}" == "-u" ]
|
||||||
then
|
then
|
||||||
User=${!value}
|
user="${!value}"
|
||||||
elif [ "${!arg}" == "-p" ]
|
elif [ "${!arg}" == "-p" ]
|
||||||
then
|
then
|
||||||
Port=${!value}
|
port="${!value}"
|
||||||
|
elif [ "${!arg}" == "-H" ]
|
||||||
|
then
|
||||||
|
hostname="${!arg}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -49,10 +92,13 @@ done
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
if [ "${i%=*}" == "--user" ]
|
if [ "${i%=*}" == "--user" ]
|
||||||
then
|
then
|
||||||
User="${i#*=}"
|
user="${i#*=}"
|
||||||
elif [ "${i%=*}" == "--port" ]
|
elif [ "${i%=*}" == "--port" ]
|
||||||
then
|
then
|
||||||
Port="${i#*=}"
|
port="${i#*=}"
|
||||||
|
elif [ "${i#*=}" == "--hostname" ]
|
||||||
|
then
|
||||||
|
hostname="${i#*=}"
|
||||||
elif [ "${i}" == "--version" ] || [ "${i}" == "-v" ]
|
elif [ "${i}" == "--version" ] || [ "${i}" == "-v" ]
|
||||||
then
|
then
|
||||||
echo "$(basename $0) v.${Version}"
|
echo "$(basename $0) v.${Version}"
|
||||||
|
@ -64,10 +110,35 @@ for i in "$@"; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo try to connect with user=${User} and port=${Port}
|
if [ "${user}" == "" ]
|
||||||
echo port=${Port}
|
then
|
||||||
|
user="${default_user}"
|
||||||
|
fi
|
||||||
|
if [ "${hostname}" == "" ]
|
||||||
|
then
|
||||||
|
hostname="${default_hostname}"
|
||||||
|
fi
|
||||||
|
|
||||||
ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile=/dev/null" -p ${Port} ${User}@localhost
|
|
||||||
|
|
||||||
|
case "${protocol}" in
|
||||||
|
"ssh")
|
||||||
|
start_ssh
|
||||||
|
;;
|
||||||
|
"rsp")
|
||||||
|
start_rsp
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "CRITICAL protocol ${protocol} uknown" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
echo try to connect with user=${user} and port=${port}
|
||||||
|
echo port=${port}
|
||||||
|
|
||||||
|
ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile=/dev/null" -p ${port} ${user}@localhost
|
||||||
|
|
||||||
|
|
||||||
# add possibility for vnc and rsp
|
# add possibility for vnc and rsp
|
||||||
|
|
Loading…
Reference in a new issue