# [SOLVED/PEBKAC] Need some handholding setting up ssh

## Aquous

Hi guys,

I need some help setting up ssh.

The idea is that I'll be able to log in to my Gentoo box from my Android tablet when something goes wrong with my computer (e.g. the display driver crashes or something like that and I want to cleanly reboot my box). I would like to use key-based authentication for this as it seems the safest and most practical option. I've managed to successfully set this up on Windows (I dual-boot Windows and Gentoo), but I can't get it to work on Gentoo. What I've done (based on http://en.gentoo-wiki.com/wiki/Public_Key_Authentication):

```
sudo /etc/init.d/sshd stop

ssh-keygen #(accepted all defaults and chose a passphrase, the key is stored in ~/.ssh/id_rsa)

#imported the id_rsa key into ConnectBot on my tablet

cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys

sudo /etc/init.d/sshd start
```

On Windows (using Cygwin), this works, i.e. I can successfully log in to my computer from my tablet. On Gentoo, my tablet simply says 'authentication using public key failed'.

Can anyone help me figure this out? Do I perhaps need to add the public key to some system-wide authorized_keys file?Last edited by Aquous on Fri Jun 22, 2012 2:30 pm; edited 1 time in total

----------

## gasparov

I didn't get what you did exactly, just to clear it up:

you made the rsa key on the tablet 

you copied the generated pub key on the gentoo machine

you added the copied key in the authorized_keys file of the gentoo machine

As far as i remember if you want to connect from the tablet to gentoo and not viceversa you just need the rsa key of the tablet on your gentoo's authorized_keys, I don't understand where you actually launched those commands you posted.

----------

## khayyam

 *Aquous wrote:*   

> On Windows (using Cygwin), this works, i.e. I can successfully log in to my computer from my tablet. On Gentoo, my tablet simply says 'authentication using public key failed'.

 

Sounds like the permissions are not set correctly on ~/.ssh ... with Windows it'll probably be read-write-execute-exploit for all parties .. but linux will need to be go-rwx

```
% ssh remote.tld

% ls -ld .ssh

drwx------ 3 khayyam users 4096 Jun 22 12:30 .ssh/
```

HTH & best ...

khay

----------

## Aquous

OK, guess I was doing it wrong.

I started over and did the following:

On my tablet: Generated a 4096-bit RSA key, empty passphrase.

Copied the generated public key to clipboard and saved it to a text file (still on my tablet).

Saved the public key to my tablet's SD card and transferred it to my computer.

On my computer: rm -rf'ed my ~/.ssh folder and created a new one, renamed the pubkey file to authorized_keys and put it in there

/etc/init.d/sshd restart

When I tried to connect, it still said the authentication failed.  :Sad: 

khayyam, my permissions on ~/.ssh are the same as yours.

The content of my ~/.ssh/authorized_keys is now:

```
ssh-rsa [yeah, censoring this part] PC/tablet
```

with no newline at the end. Is this correct?

EDIT: Never mind, I solved it. It turns out ConnectBot was trying to log in as root.   :Rolling Eyes:   :Embarassed: 

Sorry guys, looks like this was a PEBKAC issue...

----------

