…with an open minded approach

Detect ssh login from ~/.bashrc

When you login with ssh, your environment gets 2 variables defined: SSH_CONNECTION and SSH_TTY

A simple way to detect if you are inside a bash session, established from ssh-login, is to check these vars

You can put this check inside ~/.bashrc, so that it executes in all new bash-logins, so that when a ssh-login is detected you can make something happen :)

This is a simple hack to detect normal ssh-logins, but dont use this for anything too important :)

 

 

About these ads

One response

  1. Dmitry Shpakov

    Thank you dude, it works for me!

    March 24, 2014 at 10:06

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.