Tuesday, March 12, 2013

Passwordless SSH


cd $HOME [or just type cd and then enter]

the server HOME directory permission 750

chmod 700 .ssh
cd .ssh            # goto .ssh folder where below files exist

To generate id_rsa.pub and id_rsa execute below command. Press enter
if it asks for anything
[If id_rsa.pub already there no need to do this. ]
ssh-keygen -t rsa

chmod to below files on both servers.
chmod 600 authorized_keys
chmod 644 known_hosts
chmod 640 id_rsa.pub
chmod 600 id_rsa

hostkey located in: /etc/ssh/ssh_host_rsa_key.pub
To show fingerprint: ssh-keygen -l -f ssh_host_rsa_key.pub

Append remote server's hostkey to client's(local) known_hosts file
with IP as below 
[IP hostkey= comment_to_describe_key]:

Append client server's(Local) id_rsa.pub key to remote server's authorized_keys
as below.
ssh-rsa key= comment_to_describe_key 
Now connect to remote servers as below example:
ssh ruser@

It should not prompt you any password
NOTE-- There may be slight changes from OS to OS as in some OS keys been copied automatically. 

Sunday, March 3, 2013

Some useful Linux utilities-- useful tips

1- Sync two folders (below syncing each second)
         'watch -n 1 rsync -avz source destination'
 It also take care of directory structure.Also can sync remote system directory without mounting it.

2- bzcat,bzless,zcat etc commands are very useful to display the contents of single large compressed file(in some GB). If  any-time such large file need to be processed than use any of these command and pipe output to the programme which will process it.

3- Run command at remote system

ssh gauravp@machine "\unix_command"
ssh -n gauravp@machine "unix_command"
echo "unix_command"|ssh gauravp@machine

Saturday, March 2, 2013

connect internet using wvdial in Linux

Change wvdial.conf for connect to different internet connection--netconnect,bsnl,airtel

to connect command is-- wvdial dialer_name.

For reliance net connect+ its mandatory to provide username & password.

Note- A slight modification on this file will work for other ISP or other countries too.


[Dialer netconnect]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Stupid Mode = 1
Modem Type = Analog Modem
New PPPD = yes
Baud = 9600
ISDN = 0
Modem = /dev/ttyUSB0
Phone = #777
Username = ur_number
Password =  ur_number
Baud = 9600

[Dialer bsnl]
Init1 = ATE0V1
Init2 = AT+CFUN=6
Init3 = AT+CGDCONT=1,"IP","bsnlnet"
Stupid Mode = 1
Modem Type = USB Modem
Phone = *99#
Modem = /dev/ttyACM0
Username = { }
Password = { }
Baud = 460800

[Dialer airtel]
Init1 = ATZ
Init2 = at+cgdcont=1,"ip","airtelgprs.com"
Stupid Mode = 1
Modem Type = USB Modem
ISDN = 0
Phone = *99***1#
Modem = /dev/ttyUSB0
Username = a
Password = a
Baud = 9600