Technology Work

Configuring your .ssh

When you are working with a lot of servers or terminal boxes, it would be very hard typing those long text with their parameters. Like for example, i connect with four(4) servers: let’s say that the servers’ IP addresses are 123.45.6.1, 123.45.6.2, 123.45.6.3, and 123.45.6.4. So everytime I connect with the first server, I would do this:

ssh [email protected]

That would be very long, I mean what if you forgot the ip address? What if you don’t only have four(4) servers but 10? Would you be able to remember all those 10 ip? Well, you might, but it would be hard. So here’s one thing that you could do.

Scenario:
OS: Debian Etch
Desktop: KDE
Shell: bash

#1 In your home directory, type:

ls -al

This would show you all the hidden files with its details. you will be able to see that there’s a .ssh folder.

#2 Go to the .ssh folder:

cd .ssh

#3 If there’s a config file already, go immediately to step #4. If not,  do the following:

mkdir config

sudo chmod 644 config

#4 Edit the config file with your favorite editor. In my case, i use vi:

vi config

#5 Add the following using this format:

Host <hostname_that_you_want>
Hostname <the_host_name_or_ip_address>
User <your_user_name>

eg.
Host server1
Hostname 123.45.6.1
User ridvan.baluyos

Host server2
Hostname 123.45.6.2
User ridvan.baluyos

Hostname n
Hostname xxx.xxx.xxx.xxx

that’s the basic format. you could add many hosts though.

#6 In your terminal, you can then write:

ssh server1

rather than,

ssh [email protected]

It makes things easier that way. 🙂

Side Notes:

For killing a process:

ps auwx | grep -i <keyword>

The keyword there would be the name of the application, so if your firefox browser didn’t work properly or started hanging, you could type

pas auwx | grep -i mozilla

When all of the processes are displayed, look for its process id and execute this:

kill <process_id>

If it still doesn’t work, you might want to try:

kill -9 <process_id>

For checking your ip address or checking ethernet connections:

Just execute:

/sbin/ifconfig

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.