Claudiu Persoiu

Blog-ul lui Claudiu Persoiu

Archive for the ‘Linux-Unix’ Category

ssh key based authentication

without comments

The ssh key based authentication is useful when you don’t want to type the password each time. Also is useful when for instance sshfs is used and mounting takes place without entering a password.

The end result should do login with the following command:

$ ssh work


In Ubuntu the server installation is done with:

$ sudo apt-get install ssh

For other distributions the packege is usually called ssh or OpenSSH.

On server-side you must activate the public key authentication in the sshd_config file:


PubkeyAuthentication yes


On client-side the public/private key pair must be generate:

$ ssh-keygen -t rsa -b 1024

Where the type of the key is rsa and 1024 is the size. Bigger is safer.

The public key must be copied on the server using the following command:

$ ssh-copy-id -i ~/.ssh/id_rsa user@

The -i option and key path are optional, if there was generated a single key on the client in ~/.ssh directory that one will be used as default.

Right now it should work to login using the next command without prompting for password:

$ ssh user@


The last step is creating an alias, in this case it will be called “work”.

You must make a config file in the ~/.ssh directory. The file must have 600 rights, that is reading and writing only for owner.

$ cd ~/.ssh
$ touch config
$ chmod 600 ~/.ssh/config

In this file aliases will be set:

Host work
User user
IdentityFile ~/.ssh/id_rsa

At this step authentication to the previously defined host can be made with the command:

$ ssh work

To learn more about ssh aliases checkout the manual:

$ man ssh_config

Written by Claudiu Persoiu

5 April 2011 at 8:35 PM

Posted in Diverse,Linux-Unix

Tagged with

Authenticated as root on ubuntu

with 2 comments

Ubuntu is based on the sudo command, apparently eliminating the possibility of directly using the root account.

Sometimes, when a series of commands must be executed as root from console, it becomes “annoying” to use sudo command.

Even though it doesn’t seem possible you can authenticate as root.

First of all the user must have root right,  when using sudo command!

The authentication can be done in two ways:
– sudo session:

sudo -s

– using su:

sudo su

Of course the root authorization is only for the current console. But from this console, for example other consoles can be opened, and they will be running as root.

Written by Claudiu Persoiu

22 January 2011 at 1:09 PM

Posted in Diverse,Linux-Unix

Tagged with