Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to use SSH between two computers on the same domain with the same user, and I don't want to type the password. here's an example:

[user@pc1 ~]$ ssh pc2

if pc1 and pc2 are on the same domain, with NIS authentication, and I'm logging in through SSH with the same user (as I didn't specify one), I wish I didn't have to type the password again, as I already did it when logging in at pc1.

share|improve this question
add comment

5 Answers

up vote 7 down vote accepted

Your simplest path to success is with public keys.
Look in your home directory, under .ssh and see if you have id_dsa or id_rsa (and an accompanying .pub file).
The id_dsa (or rsa) is your private key. The .pub is your public key. It's a text file, so you can cat it.
Note - if you don't have these, you can create them with the ssh-keygen command.

On the other machine, cd to the .ssh directory, and edit a new file called "authorized_keys". Paste the contents of the .pub file into this (it's all one big line).

Do the same thing for the other machine, just in reverse.

Just to make sure permissions are right, run "chmod 600 ~/.ssh/authorized_keys" on both machines.

At this point, you should be able to ssh without passwords from one machine to the other.

share|improve this answer
    
This is doubly useful if you're mounting your home directory off some kind of central file server (e.g. NFS). –  Ophidian Jun 30 '09 at 22:41
add comment

Under no circumstances should you blindly trust a network connection to be who they say they are. Instead, what you can do is set up SSH keys. By distributing the public key to all the servers you want to SSH into, and the private key to those trusted computers you want to SSH from, you can get the same thing with some amount security.

Normally you should give a private key a password, to prevent disclosure, but if you make a key-pair exclusively for network authentication, it should suffice.

share|improve this answer
add comment

The easiest way to set up auth with SSH keys is as follows.

cd ~
ssh-keygen -t rsa
ssh-copy-id -i .ssh/id_rsa.pub user@remote.host
share|improve this answer
add comment

If you're using SSH public/private keys (and you should IMHO) and you're using some kind of SSH agent, like ssh-agent(1), log to pc1 with -A flag, like:

ssh -A user@pc1

This will also allow you to use agent forwarding to connect to other accounts (not necessarily with the same username), as long as your public key is propagated to given accounts@hosts.

share|improve this answer
add comment

It is possible (depending on your ssh client) to setup keys for the entire host, instead of keys for individuals. I have never used this, but there are some related links.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.