Tuesday, December 8, 2009

Password less login/copy_files through ssh

Lets assume we have two machines named kutty(192.168.1.3) & nutty(192.168.1.6)
Now follow the below steps to login from kutty to nutty without password for user vivek
Step 1:
Execute the below commands in kutty
[vivek@kutty]# ssh-keygen -t rsa (This command will generate public/private keypair, by default ssh-keygen command picks RSA encryption & by -t option we can select DSA encryption as well. But, I prefer RSA.)

[vivek@kutty]# scp /home/vivek/.ssh/id_rsa.pub vivek@192.168.1.6:/tmp (This is to copy our kutty's public key to nutty)

Step 2:
In nutty execute the below commands

[vivek@nutty]# touch /home/vivek/.ssh/authorized_keys (Need to create only if authorized_keys file not exist )

[vivek@nutty]# cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys

Now we can login with out password through ssh from kutty to nutty

[vivek@kutty ~]# ssh vivek@192.168.1.6
Last login: Mon Nov 30 18:30:00 2009 from 192.168.1.3
[vivek@nutty ~]#

Command to Configure Proxy in command Line

export 'http_proxy=http://10.1.0.30:3128'

Command to mount image file (.iso)

# mount -o loop source_file.iso /destination_directory

Adding Date And Time To Your Bash History

Edit your /etc/bashrc and append to the bottom:


export HISTTIMEFORMAT="%h/%d - %H:%M:%S "

From next login instead of:

574 tail -f /var/log/maillog
575 mailq | tail -15
576 tail -f /var/log/maillog
577 less /var/log/maillog

you get:

1002 Apr/30 - 11:46:16 grep mailadmin /var/log/maillog
1003 Apr/30 - 14:17:40 passwd mailadmin
1004 Apr/30 - 14:18:02 smbpasswd mailadmin
1005 Apr/30 - 14:50:28 history 10

Command To Open wtmp File in Linux

last -f  /var/log/wtmp.1

(or)

dump-utmp /var/log/wtmp.1

(or)

utmpdump /var/log/wtmp

Cron Tab Syntax

* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)