Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Hi, I have been trying to establish a connection between two pcs via the ssh channel. I successfully made the connection as a root user, but when i tried as a non root user i had to type in the password the make contact with the other pc. And besides this could someone tell me how exactly does this passwordless login actually work?

ssh -v and reading the sshd logs (eg /var/log/auth.log on Debian) are the place to start when debugging these types of ssh problems.

I'm assuming you are using rsa or dsa public key authentication. Basically the server sends a packet encrypted with your public key. You decrypt it with your private key and send it back to the server. The server sees that you hold the private key, authenticating your login.

Hi, I have been trying to establish a connection between two pcs via the ssh channel. I successfully made the connection as a root user, but when i tried as a non root user i had to type in the password the make contact with the other pc. And besides this could someone tell me how exactly does this passwordless login actually work?

You need to make a new key pair and add the public key to the users ~/.ssh/authorized_keys2 file on the remote machine.
Exactly the same as the way you set it up for root, but in the users home directory instead.

To set up a system so that no passwd is needed two keys must be generated and copied to a file per known-host. The two keys are called rsa and dsa, of these keys two keys will be genterated per key, a private key and a public key.

Open a terminal window and create the keys, this is done with the ssh-keygen utility. Lets create the first key.

Code:

hostname:$ssh-keygen -t rsa

The utility will ask for a file to copy the key to, just press enter, this will copy the key to the default location, (~/.ssh)
Next the utility will ask for a pass phrase, if you don't want to be bothered with entering a pass phrase just press enter, confirm again. Now you will be given a key fingerprint and the keys (id_rsa and id_rsa.pub) will be copied to your home .ssh directory.

Now create the second keys.

Code:

hostname:$ssh-keygen -t dsa

Again as with the rsa keys you will be asked for a file to copy the keys to, just press enter, and also asked for a pass phrase again if you don't want to bother with entering a pass phrase just press enter.
Now a second set of keys will be genterated and copied to the ~/.ssh directory. Ok lets change into the .ssh directory.

Code:

hostname:$cd ~/.ssh

Do a ls to list the contents of the .ssh directory the output should look something like this

Code:

id_dsa id_dsa.pub id_rsa id_rsa.pub known_hosts
hostname:~/.ssh$

Now we need to copy the public keys to a file called authorized_keys. At the terminal type

What this command has done is copied the contents of the id_rsa.pub key to a file called authorized_keys then apended the id_dsa.pub key to that same file. So now if you do a ls or list the contents of the .ssh directory you will see a new file added called authorized_keys.

Now we need to copy the authorized_keys file to the remote host we would like to ssh into without having to enter a passwd everytime. We will use the scp utility to do this, lets say the remote-host we want to ssh into has a ip of 192.168.1.100 then the command would be.

Code:

hostname:~/.ssh$scp authorized_keys 192.168.1.100:/home/username/.ssh

Make sure to enter the home directory name for the remote system, you will be prompted for a password, enter the password and the authorized_keys file will be copied to the remote hosts .ssh directory.

Now if you need to ssh into a remote-host all that is needed is to enter ssh /ipaddress/ and you will not be asked for a passwd. SSH will authenticate using the rsa and dsa keys.

Note: This can be done for the root account, but is safer if it is set up on the users account and then if needed su to root to perform any admin tasks.