SSH mit PubKey

mat

Member
Hallo zusammen,

um es vorweg zu nehmen: das Thema wurde schon behandelt und oft beschrieben, jedoch bei mir funktioniert es immer noch nicht, drehe hier bald durch...

Also: möchte per PubKeyAuthentication (und nur so) auf den Server.
Schlüssel mit ssh-keygen -t dsa erstellt, den öffentlichen nach authorized_keys kopiert (in das entspr. User-Verzeichnis) und die sshd_config entsprechend angepasst.

Allerdings kann ich mich noch immer per Passwort (von BSD -> BSD) anmelden (ssh user@maschine, dann das Passwort). Will ich aber doch gar nicht... :grumble:

Bitte, hat jemand ne Idee, trotz des häufig behandelten Themas??

Gruss
Mathias
 
...na so: :)

Port 9877
Protocol 2
#AddressFamily any
ListenAddress 192.168.10.102
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
#HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

LoginGraceTime 50
PermitRootLogin no
StrictModes yes
#MaxAuthTries 6

RSAAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile /home/mathias/.ssh/authorized_keys
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes

# Change to yes to enable built-in password authentication.
PasswordAuthentication no
PermitEmptyPasswords no
 
Hi,

ich hatte mal den Fehler gemacht, den Public-Key von vi(1) aus per copy+paste in
authorized_keys zu übernehmen! Am besten mit cat(1) die datei ssh_host_dsa_key.pub
ausgeben, dann Console-Output per copy+past in auth_keys des Servers übernehmen.

Meistens hilft dann auch den sshd im interaktiven Debug-Modus zu starten (Optionen
dazu "-Dde"). Vielleicht auch den ssh Client in Verbose (-v) Modus fahren.

Viel Erfolg!

Grüße

EDIT: hier ist meine sshd_config wo key-auth verwendet wird. Wie Du siehst (fast) alles default Werte!
Code:
#Port 22
#Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
ListenAddress MyHostName
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# Change to yes to enable built-in password authentication.
#PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable PAM authentication
#ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'no' to disable PAM authentication, account processing, 
# and session processing. If this is enabled, PAM authentication will 
# be allowed through the ChallengeResponseAuthentication mechanism. 
# Depending on your PAM configuration, this may bypass the setting of 
# PasswordAuthentication, PermitEmptyPasswords, and 
# "PermitRootLogin without-password". If you just want the PAM account and 
# session checks to run without PAM authentication, then enable this but set 
# ChallengeResponseAuthentication=no
#UsePAM yes

#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem       sftp    /usr/libexec/sftp-server
 
Zuletzt bearbeitet:
So, habs jetzt...
Im Grunde war alles richtig, was mein Problem allerdings noch war: die Berechtigung für den User, der sich anhand des PubKey einloggen soll, muss auf 0755 gestzt werden (chmod 0755 /usr/home/xyUser)

Ich bin nur glücklich das es jetzt läuft... :))
 
Das halte ich für ein Gerücht.
Würde ja bedeuten das jeder andere User in dein $HOME kann.

Code:
as@beastie ~> ls -ld ~ ~/.ssh ~/.ssh/authorized_keys
drwx------  5 as  wheel  512 Oct 15 04:25 /home/as
drwx------  2 as  wheel  512 Sep 20 16:01 /home/as/.ssh
-rw-------  1 as  wheel  610 Sep 18 10:33 /home/as/.ssh/authorized_keys
Ausserdem was hat das damit zu tun das Du kein Passwortabfrage mehr zulassen willst? Oder habe ich das falsch verstanden?
 
Zuletzt bearbeitet von einem Moderator:
Zurück
Oben