[X-Unix] Beginner Questions: alias for SSH tunnel

Jon Allen Boone ipmonger at delamancha.org
Tue May 10 07:53:50 PDT 2005


On May 10, 2005, at 10:36, dm87 at proparallax.com wrote:

> What I am trying to accomplish the creation of an alias to open the  
> SSH tunnel in terminal.  I can type in the command, it works very  
> well, but it is time consuming to type in and I usually make a lot  
> of mistakes.  I thought it would be a good thing to create an alias.

   Yes, an alias is an excellent solution to this problem.

> My .bashrc and .bash_profile files have now been edited several  
> times, and contain only commands I have typed in.  They were blank  
> when I opened them, so I assume that I can delete what I have added  
> and all will be well.

   Indeed, there is no need to have a .bash_profile nor a .bashrc  
unless you want to customize your bash experience.

> So, I have put this line of code in both .bashrc and .bash_profile:

   My .bash_profile sources my .bashrc.  My .bashrc calls the global  
bashrc, then adds my own additions.  You should put the alias in one  
file or the other, but not both, lest you have difficulties in trying  
to modify the definition at a later date.  I suggest .bashrc.

>     alias ftpME="sudo ssh -L 5000:www.mydomain.com:21  
> username at www.mydomain.com

   Aside from the missing end-quote, which I'm assuming you have in  
your .bash* files, there is nothing wrong with this line.

> When I type in ftpME at the terminal prompt, I get the error message:
>
>     -bash: ftpME: command not found

   Once you have added the alias to your .bashrc, you should "source"  
the bashrc like this:

. ~/.bashrc

   Then your alias will take effect.

    Alternatively, you could type it interactively on the command line.

> What am I doing wrong?  What file should contain the alias code?

   Hope that this helps.

--jon


More information about the X-Unix mailing list