Howdy, Stranger!

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


A Shell for SSH Tunnellers Only
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

A Shell for SSH Tunnellers Only

sleddogsleddog Member
edited December 2013 in Tutorials
sleddog@home:~$ grep myuser/etc/passwd
myuser:x:1001:1001::/home/myuser:/bin/exitonly.sh
sleddog@home:~$ 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...

sleddog@home:~$ 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.

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

Comments

Sign In or Register to comment.