2

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 [email protected]

2 Answers 2

3

You can alias it in you ~/.bashrc.

Add that line alias db_connect="ssh -L 3333:dbserver:3306 [email protected]" And reload the bashrc file with source ~/.bashrc

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

4
  • 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, 2010 at 18:54
  • Never mind. I put the command in single quotes and it worked.
    – Xeoncross
    Feb 25, 2010 at 18:56
  • You have to either relaunch your prompt or reload your bashrc with ` source ~/.bashrc` Feb 25, 2010 at 19:04
  • 1
    Behold! Ye Shall Worship The Almight Aliasing! :D
    – dag729
    Feb 25, 2010 at 19:13
0

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

You must log in to answer this question.

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