PDA

View Full Version : [ubuntu] Remove password authentication for SSH?



PremiumAlex
August 7th, 2008, 08:21 PM
Hi there!

I'm trying to get a SSH tunnel set up on my home computer so I can set up VNC through SSH on my work computer. I'm having troubles with public keys and password authentication, however. I want to disable passwords and strictly use public keys, but even with the configuration options set, I still get a password prompt. The keys also aren't working, as I removed the keys from the ~/.ssh/ folder. I also restarted ssh and the computer multiple times with no effect.

Anyone have any ideas?

Also, I've read the wiki on SSH and followed the instructions for setting up SSH w/ public keys on this thread. (http://ubuntuforums.org/showthread.php?t=30709)

The odd part is that I still get password prompts after I set


# PasswordAuthentication yes

Change to:

PasswordAuthentication no
UsePAM no

in /etc/ssh/sshd_config.

ilrudie
August 7th, 2008, 08:54 PM
What version of Ubuntu are you using? I have Hardy setup with key authenticated ssh and it works just fine.

PremiumAlex
August 7th, 2008, 09:08 PM
I'm using 8.04 with the newest kernel version.

It's just so strange. Here is how I connect through SSH, if it helps:

Let's just assume both compters are on my local network for now, to get things set up.

I have my key created on the remote machine using

ssh-keygen -t rsa

and then I manually copied the contents of id_rsa.pub to ~/.ssh/authorized_keys on my local machine (the one I want to connect to).

I then went to /etc/ssh/sshd_config on the local machine and turned password authentication and UsePAM to off. Restarted SSH and restarted the computer.

I then try to login to my system remotely:

ssh 192.168.1.xxx

and I still get a password prompt! it's craziness, I tell ya.

ilrudie
August 7th, 2008, 09:27 PM
The keys should go in ~/.ssh/authorized_keys2

also ssh -v will show you what ssh is doing. It should shed some light on what exactly is happening.

Also make sure you specify a user or you have the same username on both machines.

PremiumAlex
August 7th, 2008, 09:33 PM
All right, I'll change the authorized_keys to authorized_keys2 when I get home from work and let you know how it goes.

xc3ll
August 7th, 2008, 11:24 PM
Do you have a passphrase set for your keys (I'm not sure if ssh does it automatically) ?

If you don't, run:

$ssh-keygen -p

tortsto
December 10th, 2008, 03:28 AM
moving ~/.ssh/authorized_keys to authorized_keys2 made it work for me!

Thanks a lot!