sftp mit ChrootDirectory nicht möglich

toom

New Member
Ich habe mir Ubuntu-Server auf einer virtuellen Maschine installiert und SSH und SFTP eingerichtet. Funktioniert alles wunderbar, nur kann ich kein ChrootDirectory anlegen. Mit ChrootDirectory-Eintrag sieht meine /etc/ssh/sshd_config so aus:

Code:
Match User sftp
      ChrootDirectory /home/%u
      AllowTCPForwarding no
      X11Forwarding no
      PasswordAuthentication no
      ForceCommand /usr/lib/openssh/sftp-server

Wenn ich dann "/etc/init.d/ssh restart" ausführe erhalte ich folgende Fehlermeldung:
Code:
paul@ubuntu:~$ sudo /etc/init.d/ssh restart
/etc/ssh/sshd_config: line 81: Bad configuration option: ChrootDirectory
/etc/ssh/sshd_config line 81: Directive 'ChrootDirectory' is not allowed within a Match block

Ich habe in der Man-Page von sshd_config reingeschaut. Unter dem Schlüsselwort match ist folgender Eintrag zu lesen (kein Wort von ChrootDirectory als mgl. Parameter):
Code:
Match   Introduces a conditional block.  If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file,
             until either another Match line or the end of the file.  The arguments to Match are one or more criteria-pattern pairs.  The available criteria are User, Group, Host, and Address.  Only a
             subset of keywords may be used on the lines following a Match keyword.  Available keywords are AllowTcpForwarding, Banner, ForceCommand, GatewayPorts, GSSApiAuthentication,
             KbdInteractiveAuthentication, KerberosAuthentication, PasswordAuthentication, PermitOpen, RhostsRSAAuthentication, RSAAuthentication, X11DisplayOffset, X11Forwarding, and X11UseLocalHost.

Dann habe ich im Internet eine andere Man-Page von sshd_config gefunden (man sshd_config(5)). Hier sieht der Match-Eintrag so aus (ChrootDirectory + diverse andere Parameter zusätzlich enthalten)
Code:
Match   Introduces a conditional block.  If all of the criteria on the
             Match line are satisfied, the keywords on the following lines
             override those set in the global section of the config file,
             until either another Match line or the end of the file.

             The arguments to Match are one or more criteria-pattern pairs.
             The available criteria are User, Group, Host, and Address.  The
             match patterns may consist of single entries or comma-separated
             lists and may use the wildcard and negation operators described
             in the PATTERNS section of ssh_config(5).

             The patterns in an Address criteria may additionally contain
             addresses to match in CIDR address/masklen format, e.g.
             ``192.0.2.0/24'' or ``3ffe:ffff::/32''.  Note that the mask
             length provided must be consistent with the address - it is an
             error to specify a mask length that is too long for the address
             or one with bits set in this host portion of the address.  For
             example, ``192.0.2.0/33'' and ``192.0.2.0/8'' respectively.

             Only a subset of keywords may be used on the lines following a
             Match keyword.  Available keywords are AllowAgentForwarding,
             AllowTcpForwarding, Banner, ChrootDirectory, ForceCommand,
             GatewayPorts, GSSAPIAuthentication, HostbasedAuthentication,
             KbdInteractiveAuthentication, KerberosAuthentication,
             MaxAuthTries, MaxSessions, PasswordAuthentication,
             PermitEmptyPasswords, PermitOpen, PermitRootLogin,
             RhostsRSAAuthentication, RSAAuthentication, X11DisplayOffset,
             X11Forwarding and X11UseLocalHost.

Auf meinem Ubuntu Hardy läuft folgende OpenSSH-Version
"OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007"

Weiss jemand wieso das bei mir nicht funktioniert?
 
Ich benutze Ubuntu Hardy 8.04 Server Version.

Gibt es die Möglichkeit eine aktuelle Version über apt zu bekommen?
Oder muss ich es selbst kompilieren?
 
Alternativ könntest du auch einfach sshd zwei mal laufen lassen - mit zwei unterschiedlichen Konfigurationsdatei und anderem Port oder anderer IP Adresse.
 
Inwiefern löst das deiner Meinung nach das Fehlen der ChrootDirectory-Direktive und die damit verbundene Funktionalität?
 
Oder du aktualisierst deine komplette Distribution.

Genau das habe ich gemacht :D. Ich habe jetzt Ubuntu 8.1 Server Edition auf meiner virtuellen Maschine installiert. Bis jetzt habe ich auch wieder ssh und sftp ans Laufen gebracht. Meine openssh-Version ist nun "OpenSSH_5.1p1 Debian-3ubuntu1, OpenSSL 0.9.8g 19 Oct 2007".

Allerdings gibt es ein neues Problem, wenn ich meine sshd_config wie folgt aufsetze:
Code:
Match User sftp
      AllowTCPForwarding no
      X11Forwarding no
      PasswordAuthentication no
      ForceCommand /usr/lib/openssh/sftp-server

Dann kann ich mich mit dem ftp-Client ohne weiteres anmelden. Wenn ich aber den Match-Block nun erweiter indem ich ein ChrootDirectory hinzufüge:

Code:
Match User sftp
      ChrootDirectory /home/%u
      AllowTCPForwarding no
      X11Forwarding no
      PasswordAuthentication no
      ForceCommand /usr/lib/openssh/sftp-server
Dann kann ich mich nicht mehr anmelden. Wieso läuft das jetzt nicht mehr?

In /var/log/auth.log steht nach einem Verbindungversuch nun folgendes:
Mar 26 19:18:31 ubuntu sshd[6075]: Accepted publickey for sftp from 10.211.55.2 port 58771 ssh2

Ich habe das Verzeichnis /home/sftp komplett an root übertragen.
 
Ich habe das in der sshd_config geändert und ssh neugestartet, aber es funktioniert immer noch nicht. Wenn ich mich über die Konsole über sftp anmelden will erhalte ich folgende Fehlermeldung:
Code:
toom$ sftp sftp@10.211.55.4
Connecting to 10.211.55.4...
subsystem request failed on channel 0
Connection closed
 
neuer Versuch, vielleicht gebe ich ja diesmal was nützliches von mir...
Code:
Subsystem sftp internal-sftp
 
Back
Top