Thursday, March 13, 2014

Setup default OS using Grub2

Grub2 provides command line options for changing preference of default operating system, but many of us still do the the way editing files, Since setting up default OS is done once in months so no once remembers the defaults grub commands and everyone ends up searching up grub conf file and setting it manually. writing this blog to keep the short way documented ;)

here is the command to list all the options available 

grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2

select the desired OS you want to boot as default and
 
grub2-set-default

and make it permanent 
 
grub2-mkconfig -o /boot/grub2/grub.cfg

Monday, February 3, 2014

Password less ssh access to linux box



SSH login to linux box don't always force you to type your password again and again. lets setup ssh key based access linux machine. let me break the process into multiple things needed in this procedure.

Creating RSA based ssh keys for ssh
To create rsa key run following linux command on terminal

ssh-keygen -trsa -b2048 -f ssh_key


-t option specifies the type of key to create, we are creating RSA based keys , I have used ssh_key as file name, feel free to put file name as per your choice.
-b option specifies the number of bits in the key to create , 2048 bits is considered sufficient in general so we are using 2048 here.
-f option helps us to mention a custom name to key file, absence of this files are created with default name

Running this command will ask you enter a passphrase, press enter without entering any string
this will create two files ssh_key and ssh_key.pub

ssh_key is your private key and ssh_key.pub is your public key in this.



Configuring ssh key in target Linux machine

Next this is to configure ssh key in linux machine where we want to login ssh to target machine with your user


now add content of your public ssh key to ~/.ssh/authorized_keys
authorized_keys should be owned by your user and should have permissions 400
.ssh directory should also be owned by your user and permission should be 600

once done you can log-out from machine

Connecting to remote host using your key

You are all set to ssh to your linux machine using your private ssh key
by default private key will have permission 400, make file has same permissions.
To ssh to host use following syntax

ssh -i ssh_key user@hostname
in case you have custom port you need to add -p option with port number,
ssh -i ssh_key user@hostname -p 23


Feel free to post your queries if any