ssh user@ip geht auf einem server und beim andere wieder nicht.

FreeBSD, Gentoo, openSUSE, CentOS, Ubuntu, Debian
blnsnoopy26
Posts: 660
Joined: 2002-10-19 14:01
 

ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by blnsnoopy26 »

Hi,

Nach dem ich nun lange rumprobiert habe, wollte ich euch da mal fragen und zwar dreht es sich um folgendes.

Ich möchte mich von server1 auf server2 (nicht meine eigenen Server) per ssh user@ip auf den anderen server verbinden, was auch funktioniert nur aber nicht beim 2. Remote Server.

Es wurde mit ssh-keygen -b 4096 -t rsa ein schlüsselpaar erzeugt.

Dann habe ich auf dem remoteserver ein touch authorized_keys gemacht und dann die datei mit joe authorized_keys geöffnet.

anschliessend auf dem localen rechner ein cat id_rsa.pub den schlüssel kopiert und auf den remoteserver in die authorized_keys reinkopiert und gespeichert. Die datei authorized_keys hat die Rechte 644 und Ownder web1:ftponly und der Ordner .ssh hat auf beiden Servern chmod 0755 und owner web1:ftponly.

Nachdem der pubkey dort gespeichert ist, möchte ich mich vom localserver via ssh user@ip einloggen, aber der verlangt jedesmal ein Password egal was ich mache.

So nagut sagte ich, dann teste ich das mal mit meinem Server.
Ich packe mein pubkey in dem von dem anderen user seinen lokalen authorized_keys und versuchte per ssh user@ip auf den Server zu connecten, was ohne weiteres gelingt und ohne Password abfrage.

So zurück zu den Servern von dem User und ich versuchte mal von lokal nach lokal mit dem pubkey zu connecten, was auch gelingt ohne Password abfrage. In diesen beiden fällen trägt er beides in die known_hosts ein ohne nach dem PW zu fragen.

Nur von dem User seine Server der Remote da will er immer ein Password haben, obwohl ich die selben Prozeduren vollziehe wie mit meinen eigenen Server oder auch mit dem user seinen loaklen Server.

Er möchte perdu nicht von loakl nach remote ohne password, weil der pubkey wurde auch da eingetragen und will wie gesagt dennoch ein Password haben.

Hier einmal die sshd_configs von server1 (loakl) des users:

Code: Select all

Port 22
Protocol 2
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#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 yes
#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

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable support for the deprecated 'gssapi' authentication
# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included
# in this release. The use of 'gssapi' is deprecated due to the presence of
# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not susceptible to.
#GSSAPIEnableMITMAttack no


# Set this to 'yes' to enable 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 yes
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem       sftp    /usr/lib/ssh/sftp-server

# This enables accepting locale enviroment variables LC_* LANG, see sshd_config(5).
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
Und hier die ssh config von server2 (remote) des users:

Code: Select all

Port 22
Protocol 2
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#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 yes
#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

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable support for the deprecated 'gssapi' authentication
# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included
# in this release. The use of 'gssapi' is deprecated due to the presence of
# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not susceptible to.
#GSSAPIEnableMITMAttack no


# Set this to 'yes' to enable 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 yes
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem       sftp    /usr/lib/ssh/sftp-server
So und hier die keys mit ihren rechten

server1 (loakl)

Code: Select all

drwx------   2 web1 ftponly 4096 Nov 20 12:15 .ssh <- habs auch mit 0755 versucht

drwx------  2 web1 ftponly 4096 Nov 20 12:15 .
dr-xr-x---  8 web1 www     4096 Nov 19 16:56 ..
-rw-------  1 web1 ftponly 3243 Nov 20 10:52 id_rsa
-rw-r--r--  1 web1 ftponly  735 Nov 20 10:52 id_rsa.pub
-rw-r--r--  1 web1 ftponly  222 Nov 20 12:15 known_hosts
Server2 (remote)

Code: Select all

drwxr-xr-x   2 web1 ftponly  4096 Nov 20 12:14 .ssh <- auch mit 0700 versucht.

-rw-r--r--   1 web1 ftponly  736 Nov 20 12:08 authorized_keys
Wenn ich von meinem eigenen wie gesagt auf den user server 1 mich per key einloggen will geht das, aber nicht auf server2 von dem user.

Wo kann das Problem liegen, das er das Perdu nicht macht?

Weitere infos:

Server1 ist ein Vserver
Server2 normaler rootserver


Auf beiden servern läuft suse 9.3 als OS
Ich habe alle möglichkeiten durch und habe keine Lösung gefunden, warum er bei den server2 immer ein PW will wenn ich per ssh user@ip mich einloggen will, wobei beim vserver alles ohne probleme funktioniert.

Wäre nett, wenn da jemand eine Lösung hätte.
Roger Wilco
Posts: 5923
Joined: 2004-05-23 12:53
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by Roger Wilco »

Schau dir die Ausgabe von `ssh -v user@ip` bzw. `ssh -vv user@ip` (falls ersteres nichts bringt) von beiden Servern an.
Ich habe übrigens PAM im Verdacht...
blnsnoopy26
Posts: 660
Joined: 2002-10-19 14:01
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by blnsnoopy26 »

Hi,

Hier mal die ausgabe von ssh -v

Code: Select all

web1@vs161043:~/.ssh> ssh -v web1@62.75.xxx.xxx
OpenSSH_3.9p1, OpenSSL 0.9.7e 25 Oct 2004
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 62.75.xxx.xxx [62.75.xxxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /srv/www/web1/.ssh/identity type -1
debug1: identity file /srv/www/web1/.ssh/id_rsa type 1
debug1: identity file /srv/www/web1/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.9p1
debug1: match: OpenSSH_3.9p1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.9p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '62.75.xxx.xxx' is known and matches the RSA host key.
debug1: Found key in /srv/www/web1/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /srv/www/web1/.ssh/identity
debug1: Offering public key: /srv/www/web1/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /srv/www/web1/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
viel kann ich daraus leider nicht erkennen.
lord_pinhead
Posts: 774
Joined: 2004-04-26 15:57
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by lord_pinhead »

Code: Select all

Port 22
Protocol 2

# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

#PAMAuthenticationViaKbdInt no
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel VERBOSE
#LogLevel INFO

# Authentication:
LoginGraceTime 30
#PermitRootLogin yes
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      %h/.ssh/authorized_keys

#RhostsAuthentication no
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no

PermitEmptyPasswords no

PasswordAuthentication no

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
#PrintLastLog no
KeepAlive yes
UseLogin no

Subsystem       sftp    /usr/lib/sftp-server
So sieht das ganze eigentlich bei mir aus. Was bei dir irgendwie fehlt ist der richtige Pfad zu den Keys ( %h/.ssh/authorized_keys ), da fehlt die Variable. Was noch auskommentiert ist, ist RSAAuthentication, aber das is ja laut manpage nur für Protokoll Version 1.
blnsnoopy26
Posts: 660
Joined: 2002-10-19 14:01
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by blnsnoopy26 »

Hi,

Also hab mal deine Einstellung versucht und es geht nicht - keine chance. An irgendwas muss es ja liegen, aber ich komme nicht auf den Fehler :-(

Ich hoffe dennoch das hier noch jemand eine zündene Idee hat.
captaincrunch
Userprojekt
Userprojekt
Posts: 7066
Joined: 2002-10-09 14:30
Location: Dorsten
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by captaincrunch »

Ich an deiner Stelle würd's einfach mal mit einer Schlüssellänge für "Normalsterbliche" (in Worten 1024 oder 2048) probieren.
DebianHowTo
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
blnsnoopy26
Posts: 660
Joined: 2002-10-19 14:01
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by blnsnoopy26 »

Hi,

Habe ich gerade gemacht nur ein schlüssel mit 1024 stärke, aber auch hier will er dann ein Password haben:

Code: Select all

web1@vs161043:~/.ssh> ssh -v web1@62.75.xxx.xx
OpenSSH_3.9p1, OpenSSL 0.9.7e 25 Oct 2004
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 62.75.xxx.xx [62.75.xxx.xx] port 22.
debug1: Connection established.
debug1: identity file /srv/www/web1/.ssh/identity type -1
debug1: identity file /srv/www/web1/.ssh/id_rsa type 1
debug1: identity file /srv/www/web1/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.9p1
debug1: match: OpenSSH_3.9p1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.9p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
The authenticity of host '62.75.xxx.xx (62.75.xxx.xx)' can't be established.
RSA key fingerprint is 39:ec:84:48:59:ac:03:68:b1:54:de:65:1c:16:26:e5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '62.75.xxx.xx' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /srv/www/web1/.ssh/identity
debug1: Offering public key: /srv/www/web1/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /srv/www/web1/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
Password:
Der Server scheint mir da ein wenig komisch zu sein, aber habe jede erdenkliche einstellung versucht, aber keine führte zum Ergebnis :(
captaincrunch
Userprojekt
Userprojekt
Posts: 7066
Joined: 2002-10-09 14:30
Location: Dorsten
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by captaincrunch »

OKOK, dann halt das:
Die datei authorized_keys hat die Rechte 644 und Ownder web1:ftponly und der Ordner .ssh hat auf beiden Servern chmod 0755 und owner web1:ftponly.
Mit den Rechten kann das nicht klappen. Die Files unter .ssh (und möglichst auch das Directory selbst) brauchen 600.
DebianHowTo
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
blnsnoopy26
Posts: 660
Joined: 2002-10-19 14:01
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by blnsnoopy26 »

Ok werds mal probieren.

edit: also geht immer noch nicht, aber wenn ich die keyfile vom remite in das root .ssh packe und mich von local einlogge, dann ist alles ok und er will kein Password haben. Nur beim User web1.

Werd mal ein neuen User anlegen mal sehn was passiert.
blnsnoopy26
Posts: 660
Joined: 2002-10-19 14:01
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by blnsnoopy26 »

Hi,

So nach dem ich nun ein neuen Webuser angelegt hatte ging das AUTH ohne Probleme. Aber danke trotzdem für die unterstützung :-)
oxygen
Posts: 2138
Joined: 2002-12-15 00:10
Location: Bergheim
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by oxygen »

CaptainCrunch wrote:OKOK, dann halt das:
Die datei authorized_keys hat die Rechte 644 und Ownder web1:ftponly und der Ordner .ssh hat auf beiden Servern chmod 0755 und owner web1:ftponly.
Mit den Rechten kann das nicht klappen. Die Files unter .ssh (und möglichst auch das Directory selbst) brauchen 600.
hm. Also über die Directory Rechte müsstest du nochmal nachdenken, ich würde hier 700 empfehlen ;)
captaincrunch
Userprojekt
Userprojekt
Posts: 7066
Joined: 2002-10-09 14:30
Location: Dorsten
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by captaincrunch »

Argh...jau, das wäre schon sinnig. ;)
DebianHowTo
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq"|dc
blnsnoopy26
Posts: 660
Joined: 2002-10-19 14:01
 

Re: ssh user@ip geht auf einem server und beim andere wieder nicht.

Post by blnsnoopy26 »

Hi,

Jo habs auch mit 700 gemacht, weil bei 600 hast garkein zugriff mehr auf den Ordner als normaler webuser :-)

Aber scheint jetzt alles zu laufen.