4

I have some Amazon EC2 instances that run Ubuntu 10.04.1 LTS.

Every time I connect to those instances I run a couple of simple commands, like a cd <repository>, a git status etc.

How can I add them to a script / to which script should I add them so they would be automatically ran every time, on SSH connect?

Marius Butuc
  • 4,811

2 Answers2

4

The solution is basically to run a script on login.

Since Bash looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

I did a simple ls -la ~, saw that from that hierarchy .profile was the first only one available, so I just appended my commands here.

Problem solved!

Marius Butuc
  • 4,811
3

You can add all your commands in a single script and can call the script through the SSH line.

For eg. I will dump all the commands in /home/vidyadhar/commands.sh At the time of ssh i will do it as follows ssh vidyadhar@machine `/home/vidyadhar/commands.sh'

Vidyadhar
  • 1,450