Kann sich nicht über ssh auf meinem Rechner anmelden

633
Nick

Immer wenn ich einen Benutzer zur "sftp" -Gruppe hinzufüge, sodass ich chroot verwenden kann, kann ich keine Verbindung mehr über SSH herstellen, und es wird angezeigt: " Chdir konnte nicht in das Ausgangsverzeichnis / home / sftp_user: Keine solche Datei oder Verzeichnis " und " Dieser Dienst lässt zu Nur Sftp-Verbindungen ". Wenn ich den Besitzer von / home / sftp_user auf sftp_user eingestellt habe, kann ich mich anmelden, aber chroot funktioniert nicht mehr. Wie kann ich das beheben, damit ich auch SSH verwenden und chroot verwenden kann (nur bei SFTP, nicht bei SSH)?

# Package generated configuration file # See the sshd_config(5) manpage for details_  # What ports, IPs and protocols we listen for Port 22 # Use these options to restrict which interfaces/protocols sshd will bind to #ListenAddress :: #ListenAddress 0.0.0.0 Protocol 2 # HostKeys for protocol version 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key #Privilege Separation is turned on for security UsePrivilegeSeparation yes  # Lifetime and size of ephemeral version 1 server key KeyRegenerationInterval 3600 ServerKeyBits 1024  # Logging SyslogFacility AUTH LogLevel INFO  # Authentication: LoginGraceTime 120 PermitRootLogin no StrictModes yes  RSAAuthentication yes PubkeyAuthentication yes #AuthorizedKeysFile %h/.ssh/authorized_keys  # Don't read the user's ~/.rhosts and ~/.shosts files IgnoreRhosts yes # For this to work you will also need host keys in /etc/ssh_known_hosts RhostsRSAAuthentication no # similar for protocol version 2 HostbasedAuthentication no # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication #IgnoreUserKnownHosts yes  # To enable empty passwords, change to yes (NOT RECOMMENDED) PermitEmptyPasswords no  # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no  # Change to no to disable tunnelled clear text passwords #PasswordAuthentication yes  # Kerberos options #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes  # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes  X11Forwarding no X11DisplayOffset 10 PrintMotd no PrintLastLog yes TCPKeepAlive yes #UseLogin no  #MaxStartups 10:30:60 #Banner /etc/issue.net  # Allow client to pass locale environment variables AcceptEnv LANG LC_*  Subsystem sftp internal-sftp  # 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 and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin yes". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. UsePAM yes  Match Group sftp ChrootDirectory %h ForceCommand internal-sftp AllowTcpForwarding no 
1
Bitte [bearbeiten] Sie Ihre Frage, um alle relevanten Zeilen aus der sshd-Konfigurationsdatei auf dem Server aufzunehmen. Kenster vor 6 Jahren 0

1 Antwort auf die Frage

0
Peter

Eigentlich glaube ich nicht, was Sie fragen, ist möglich.

Aus dem sshd_config-Handbuch:

 ChrootDirectory Specifies the pathname of a directory to chroot(2) to after authentication. At session startup sshd(8) checks that all components of the pathname are root-owned directories which are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directory. 

Damit die chroot funktionieren kann, muss das Verzeichnis root sein. Deshalb funktioniert es nicht, wenn Sie den Besitzer von / home / sftp_user ändern.

Wenn der Eigentümer jedoch korrekt ist, funktioniert chroot, aber Sie versuchen, auf einen Pfad (Ihr Heimatverzeichnis) zuzugreifen, der sich außerhalb der chroot befindet. Wenn Sie möchten, dass dies funktioniert, müssen Sie den Home-Ordner in der Chroot erstellen. Wenn Sie also zu / home / sftp_user chrootiert werden, müssen Sie / home / sftp_user / home / sftp_user erstellen.

Beim Verbinden gibt es keine Möglichkeit, dass sshd feststellen kann, ob Sie "ssh" oder "sftp" ausführen möchten. Sie müssen also mit einer anderen Methode differenzieren. Vielleicht ein SFTP-spezifischer Account oder etwas.

Ja, ich dachte mir, ich musste verschiedene Konten verwenden. :( Trotzdem danke. Nick vor 6 Jahren 0