Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every time I login into my computer I start a SSH connection to a remote computer for database work. How can I automate this in Ubuntu so that I don't have to type this in each time I login to my computer?

ssh -L 3333:dbserver:3306 user@othersite.com
share|improve this question
up vote 3 down vote accepted

You can alias it in you ~/.bashrc.

Add that line alias db_connect="ssh -L 3333:dbserver:3306 user@othersite.com" And reload the bashrc file with source ~/.bashrc

And now you only have to type db_connect to ssh to your database server.

share|improve this answer
    
Hmm.. this isn't working now that I have logged out and tested it. Do you need to type anything else before "db_connect" in the prompt? It just says "command not found". – Xeoncross Feb 25 '10 at 18:54
    
Never mind. I put the command in single quotes and it worked. – Xeoncross Feb 25 '10 at 18:56
    
You have to either relaunch your prompt or reload your bashrc with ` source ~/.bashrc` – Loïc Wolff Feb 25 '10 at 19:04
1  
Behold! Ye Shall Worship The Almight Aliasing! :D – dag729 Feb 25 '10 at 19:13

You can modify your shell configuration to execute commands on startup. For a bash shell, simply edit ~/.bashrc and add your connection line.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .