14 April, 2009

SSH shortcuts

ssh -p66666 rezuan@192.168.1.1 -L13128:localhost:3128 -X

There you go. Just another long ssh commands that you gonna forget. How about those IP addresses ? And the port numbers? Can you remember every single one of them? Fuck no, of course.

I hate those long strings dammit.

When you do advance stuff on ssh, it goes without saying; that the ssh command will be very long. Now, here's a trick to make the long strings go away. Under your "home" directory, find your hidden ssh folder and edit the "config" file. 

cd /Users/rezuan/.ssh && vim config

If you cannot find the file, you can create it. Let's edit the file based on the long ssh command like the above. Here's the end result :-

Host www # the shorcut "name"
User rezuan # username
Port 66666  # port number
HostName 192.168.1.1 # the IP address or host name

Save the file. Now, type this :-

ssh www

Now that's better, right ? Please leave your comments.

4 comments:

Phonont said...

Thanks for sharing, that's a new method to me. The usual trick I do is to edit my .bashrc file (/home/.bashrc) and define my custom commands in it using:-

alias sshrezuan='ssh -p66666 rezuan@192.168.1.1 -L13128:localhost:3128 -X'

I can then just type sshrezuan at the terminal to do the job. The above method also works for any other commands (not just ssh) you specify in between the apostrophes. Salam.

Rezuan Asrah said...

Phonont, thanks for dropping by.

This technique works on "scp" program as well. Once you configure your config file & using example above, here's the shorten command :-

scp www:/tmp/some-file.txt .

Short & sweet. I like.

Are you on Ubuntu or something?

Phonont said...

Sweet.

Yeah I've been on Ubuntu for almost 2 years now and I use unix commands on daily basis for work and pleasure. The nice thing I like about Ubuntu is its Virtual Machine so I can still work with my peers who are hopelessly hooked to Windows.

SSS said...

Tuan,

Maafkan kami kerana membuat jemputan kepada Tuan secara am seperti dibawah:-

Yang berbahagia Dato/Datin/Tuan/Puan/Saudara/Saudari,

Dengan segala hormatnya kami memaklumkan bahawa kami akan melancarkan portal “Satu Sekolah Untuk Semua (SSS)” di

http://satusekolahuntuksemua.wordpress.com.

Kami menjemput anda untuk melayari laman web tersebut selepas Sambutan Merdeka 12tengahmalam pada 31 Ogos 2009. Anda dipersilakan untuk melayari tab “e-patriot”

(http://satusekolahuntuksemua.wordpress.com/patriotsinsuppor/)

di mana kami telahpun menyenaraikan laman citra anda di bawah senarai “e-patriot” (“Patriots displaying SSS Logo”). Kami ingin merakamkan rasa penghargaan kami yang tidak terhingga di atas sokongan anda terhadap Kempen SSS ini apabila anda telah mempamirkan logo SSS di laman citra anda. Terima kasih di atas sokongan berterusan anda terhadap Kempen SSS ini.

______________________

It is our honor to inform you that we will be launching "Satu Sekolah Untuk Semua (SSS)" portal at

http://satusekolahuntuksemua.wordpress.com

Please visit the website after the 12midnite Merdeka celebration on 31 August 2009 and check out the "e-patriot" tab

(http://satusekolahuntuksemua.wordpress.com/patriotsinsuppor/).

We have listed your blog site under the "e-patriot" list (Patriots displaying SSS Logo). We wish to record our utmost appreciation for your support toward SSS campaign by displaying SSS logo at your blog site. Thank you for your continuous support toward the SSS campaign.


Terima kasih.

Satu Sekolah Untuk Semua