2015年7月1日 星期三

[How To] identify a ssh bash session in linux

Very simple just edit .bash_profile

= = =
#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc
skip_x="0"

if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
    echo "THIS IS AN SSH SESSION"
    skip_x="1"
fi


#check if x started


ps aux | grep tty |grep startx 2>&1 > /dev/null
if [ "$?" == "0" ]; then
    skip_x="1"
fi

if [ "$skip_x" == "0" ]; then
    exec startx
fi

= = =

沒有留言:

張貼留言