Monthly Archives: March 2013

Publickey auf SSH-Target: Login ohne Passwort

Anleitung

user@notebook $ ssh-keygen -t rsa
user@notebook $ cat .ssh/id_rsa.pub | \
                ssh user@server 'cat >> .ssh/authorized_keys'

Now without password
user@notebook $ ssh user@server
user@server $

Diverses

Ursache:

root@target:~ /etc/rc.d/S16openssh stop
root@target:~ /usr/sbin/sshd -d
[...]
Connection from 192.168.1.1 port 59187
[...]
debug1: trying public key file /home/.ssh/authorized_keys
Authentication refused: bad ownership or modes for directory /home

Lösung:
Im beiliegenden Script ändert sich in der Benutzerverwaltung der Benutzer “root”:
Home-Verzeichnis: /root
Shell: /bin/bash

andreas@host:~ ssh-keygen -t rsa
andreas@host:~ ssh-keygen -t dsa
andreas@host:~ ssh-copy-id -i ~/.ssh/id_rsa.pub root@target
andreas@host:~ ssh-copy-id -i ~/.ssh/id_dsa.pub root@target

Kopiert die zwei Publickeys aufs Target ins ~/.ssh/authorized_keys

Da das Verzeichnis /root die Berechtigung “drwx——” hat (nur User-Berechtigt), erlaubt OpenSSH nun über ein Publickey einzuloggen.

Wenn es noch nicht funktioniert, geh über die Serial-Console, stoppe den OpenSSH-Server und starte ihn im Debug-Modus:

root@target:~ /etc/rc.d/S16openssh stop
root@target:~ /usr/sbin/sshd -d

Das gleiche Spiel auf Client-Seite (mit Verbose-Flag!!):

andreas@host:~ ssh -v root@target

SSH ohne Passwort — Kurze Anleitung zur Nutzung
SSH login without password
SSH Without a Password
SSH/OpenSSH/Keys