/usr/sbin/securetelnetshell
Code: Select all
#!/bin/sh
#frontend for ssh, secure telnet.
#(c) Barry Kauler 2004
#2007 Lesser GPL licence v2 (refer: /usr/share/doc/legal)
#120331 fix help url.
#130515 gettexted by robwoj44
export TEXTDOMAIN=securetelnetshell
export TEXTDOMAINDIR=/usr/share/locale
export OUTPUT_CHARSET=UTF-8
. gettext.sh
[ -f /etc/securetelnetrc ] && . /etc/securetelnetrc
HDRMSG="$(gettext '#Configuration file for secure telnet. See Network menu.')"
while [ 1 ]
do
RETSTR=`Xdialog --wmclass "securetelnet" --title "$(gettext 'Secure telnet')" --stdout --left --separator "|" --help "" --3inputsbox "$(gettext 'ssh can be used for secure remote login,\ninvoked with the format:\n ssh -l username -p port hostname\nI suggest try port 22, if not known.')" 0 0 "$(gettext 'Hostname:')" "$SSHHOSTNAME" "$(gettext 'Port:')" "$SSHPORT" "$(gettext 'Username:')" "$SSHUSERNAME"`
RETVAL=$?
case $RETVAL in
0) #ok
RETHOSTNAME=`echo -n "$RETSTR" | cut -f 1 -d "|"`
RETPORT=`echo -n "$RETSTR" | cut -f 2 -d "|"`
RETUSERNAME=`echo -n "$RETSTR" | cut -f 3 -d "|"`
echo "$HDRMSG" > /etc/securetelnetrc
echo "SSHHOSTNAME=\"${RETHOSTNAME}\"" >> /etc/securetelnetrc
echo "SSHPORT=\"${RETPORT}\"" >> /etc/securetelnetrc
echo "SSHUSERNAME=\"${RETUSERNAME}\"" >> /etc/securetelnetrc
echo '#!/bin/sh' > /tmp/runssh.sh
echo -e "ssh -l $RETUSERNAME -p $RETPORT $RETHOSTNAME 2>/tmp/scratch1.txt" >> /tmp/runssh.sh
echo 'if [ ! $? -eq 0 ];then' >> /tmp/runssh.sh
echo -e "ERRSTR=\"\`cat /tmp/scratch1.txt\`\"" >> /tmp/runssh.sh
echo -en "Xdialog --wmclass \"securetelnet\" --title \"$(gettext 'Secure telnet')\" --infobox \"$(gettext 'Failed to execute:')" >> /tmp/runssh.sh
echo -n '\n' >> /tmp/runssh.sh
echo -n " ssh -l $RETUSERNAME -p $RETPORT $RETHOSTNAME" >> /tmp/runssh.sh
echo -n '\n' >> /tmp/runssh.sh
echo -n "$(gettext 'ssh error message:')" >> /tmp/runssh.sh
echo -n '\n' >> /tmp/runssh.sh
echo '$ERRSTR" 0 0 40000' >> /tmp/runssh.sh
echo 'fi' >> /tmp/runssh.sh
sync
chmod 755 /tmp/runssh.sh
rxvt -bg "#ff80e0" -name "$(gettext 'securetelnet')" -title "$(gettext 'Secure telnet')" -e "/tmp/runssh.sh"
break
;;
1) #cancel
break
;;
2) #help
#defaulthtmlviewer file:///usr/share/doc/ssh.htm &
defaultbrowser http://linux.die.net/man/1/ssh &
;;
*)
break
;;
esac
done