Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on LowEndTalk.com
A Shell for SSH Tunnellers Only
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

A Shell for SSH Tunnellers Only

sleddogsleddog Member
edited December 2013 in Tutorials
[email protected]:~$ grep myuser/etc/passwd
myuser:x:1001:1001::/home/myuser:/bin/exitonly.sh
[email protected]:~$ cat /bin/exitonly.sh
#!/bin/bash

HELPMSG='Type "exit" and press enter to close the connection.'
HOSTNAME=`hostname`
PROMPT="${LOGNAME}@${HOSTNAME}:~$ "

# Debian 7: touch ~/.hushlogin and create ~/motd to have per-user
# motd messages.
if [[ -e "${HOME}/.hushlogin" && -e "${HOME}/motd" ]]; then
    cat ${HOME}/motd
fi

echo
echo "Connection established."
echo $HELPMSG
echo

COMMAND=' '

while [ "${COMMAND:0:4}" != "exit" ]; do
    echo -n "$PROMPT"
    read COMMAND
    if [ -z "$COMMAND" ]; then
        continue
    elif [ "${COMMAND:0:4}" != "exit" ]; then
        echo $HELPMSG
    fi
done

exit 0

Example...

[email protected]:~$ ssh -p 22 -D 9999 -i /home/sleddog/.ssh/myuser-key [email protected] 
Creating connection...

                   .-.
      .-._    _.../   `,    _.-.
      |   `'-'    \     \_'`   |
      \            '.__,/ `\_.--,
       /                '._/     |
      /                    '.    /
     ;   _                  _'--;
  '--|- (_)       __       (_) -|--'     Hello Kitty :)
  .--|-          (__)          -|--.
   .-\-                        -/-.
  '   '.                      .'   `
        '-._              _.-'
            `""--....--""`

Connection established.
Type "exit" and press enter to close the connection.

[email protected]:~$ ls
Type "exit" and press enter to close the connection.
[email protected]:~$ rm * -rf
Type "exit" and press enter to close the connection.
[email protected]:~$ what do I do next?
Type "exit" and press enter to close the connection.
[email protected]:~$ exit
Connection to server.com closed.

Comments

Sign In or Register to comment.