Monday, September 12, 2011

ssh-keygen - password less login

To login From HostA To HostB Hostc, HostD HostE etc .... with out password.


On HOSTA (From where you connect)

$ ssh-keygen -t rsa

This will create a file
id_rsa.pub inside /home/user/.ssh

File:-  id_rsa.pub is a Public Key
File:-  id_rsa is a Private Key ( No need to copy this)



Now need to copy the id_rsa.pub(inside /home/user/.ssh/) to all hosts you want to login password less (for eg. to login to HostB,HostC,HostD,HostE etc...)

Enter password after prompting on below commands once.
$ssh-copy-id -i /scratch/aime/.ssh/id_rsa.pub oracle@hostb.us.oracle.com
$ssh-copy-id -i /scratch/aime/.ssh/id_rsa.pub oracle@hostc.us.oracle.com
$ssh-copy-id -i /scratch/aime/.ssh/id_rsa.pub oracle@hostd.us.oracle.com
$ssh-copy-id -i /scratch/aime/.ssh/id_rsa.pub oracle@hoste.us.oracle.com


Now Try:

$ ssh oracle@Hostb
Last login: Mon Sep 12 17:23:06 2011 from dhcp-singapore-test-1-vpnpool-10-191-74-134.vpn.hosta.com
[oracle@hosta ~]$

Likewise try:
$ ssh oracle@hostc

$ ssh oracle@hostd

$ ssh oracle@hoste

This will connect without password.
















Friday, September 2, 2011

For changing all .htm files in directory to .html files

sriram@ubuntu:~/scripts$ for file in *.htm; do mv "$file"  ${file%.htm}.html; done
sriram@ubuntu:~/scripts$ ls
10.html  2.html  4.html  6.html  8.html  test
1.html   3.html  5.html  7.html  9.html
sriram@ubuntu:~/scripts$

Killing all Stopped Jobs

$Jobs (Command shows 4 jobs all stopped , after I did a (Ctrl+z), Now i want to kill all that.

To List all jobs with pid's

bash-3.2$ jobs -p (will list all the pid's of jobs)

To kill those pid's
bash-3.2$kill -9 `jobs -p`