Domain Name Yahoo

Easy Help Troubleshoot Your Linux Box



  

How to login SSH without password

The answer is using private-key & public-key.
Theory is very simple, first generate pair key (Private&public key ) then put the public key into the server machine, so when another machine request login from ssh, it will compare the public key on server machine with the private-key.

Here is the example.

You want to login from computer A as root and Computer B as root.
From computer A, you generate the pair-key ( public&private key ).

[root@A ~]# mkdir .ssh
[root@A ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
11:42:12:25:16:cc:e2:5e:32:d7:72:48:20:78:25:e2 root@A

note : Just hit enter to empty the passphrase.

[root@A ~]# cat .ssh/id_rsa

Copy all the string into clipboard first.
On Machine B, create the directory .ssh , usually this folder is already exists

[root@B ~]#  mkdir .ssh

Check B authorized key file on the sshd config

[root@B ~]# cat /etc/ssh/sshd_config | less

You will find a line contains

AuthorizedKeysFile      .ssh/authorized_keys

that means the authorized_keys is in the $HOME/.ssh/authorized_keys
Therefor you need to paste the clipboard string copied from public key machine A

And you are done. You may try to login ssh from machine A. Meanwhile keep your eyes on the log of machine B

[root@B ~]# tail -f /var/log/secure
Authentication refused: bad ownership or modes for directory /root

The common failure is about the permission, you need to change the /root , .ssh and authorized_keys into 700 on machine B.

Thats it. Thanks God … I did it. :D

July 31st, 2009 Posted by admin | CentOS, General, Ubuntu, ssh | no comments

Force Kill

Kill running process is important. When you have software ruining your machine, just kill them.
But hey, some process is not easy to kill, and that is happening to me.

I found this solution when you already tried killing process on unix with the standard syntax kill PID number.
You can get PID number by running syntax # ps aux

Shell syntax to force kill the process is

# kill -9 PIDnumber

Hope this will helps.

July 7th, 2009 Posted by admin | CentOS, General, Ubuntu, Uncategorized, ssh | no comments

Welcome Message on SSH

Trick to create the welcome message after user logged into ssh of your server.
Edit file motd on /etc

# vi /etc/motd

This computer system is for authorized users only. All activity is logged and regulary checked by systems personal. Individuals using this system without authority or in excess of their authority are subject to having all their services revoked. Any illegal services run by user or attempts to take down this server or its services will be reported to local law enforcement, and said user will be punished to the full extent of the law. Anyone using this system consents to these terms.

Save it, log out then login again.
The message will appear after you logged in.

February 25th, 2009 Posted by admin | General, ssh | no comments