Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Probleme mit Samba, NFS, FTP und Co.
Antworten
Potie
Beiträge: 20
Registriert: 13.04.2014 17:11:24

Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von Potie » 10.02.2016 17:00:25

Guten Abend Community,
Ich würde gerne einen Bekannten erlauben via Sftp und Filezilla Files auf meinem Server zu laden,
Ich habe mich eigentlich strikt nach dieser Anleitung gehalten https://www.digitalocean.com/community/ ... ead-of-ftp (Hoffe Links in andere Blogs sind erlaubt)
Ich hab einen neuen User Angelegt, nennen wir ihn mal "Tester" das Passwort entfernt.
Einen Keys erzeugt der dann in /home/Tester liegt
Wie in der Anleitung beschrieben konvertiert
ssh-keygen -e -f ~home/Tester/.ssh/authorized_keys | sudo tee /etc/proftpd/authorized_keys/Tester.
Das sollte doch alles soweit passen?
Mit FileZilla den PrivatKey importiert und versucht über Port 2222 zu connecten.
Doch ich komme einfach nicht auf den Server

Code: Alles auswählen

Status:	Verbinde mit xx.xx.xx.xx:2222...
Status:	Verbindung hergestellt, warte auf Willkommensnachricht...
Antwort:	SSH-2.0-mod_sftp/0.9.9
Port ist natürlich frei, und meine config sieht so aus:

proftpd.conf

Code: Alles auswählen

#
# /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file.
# To really apply changes, reload proftpd after modifications, if
# it runs in daemon mode. It is not required in inetd/xinetd mode.
# 

# Includes DSO modules
Include /etc/proftpd/modules.conf

# Set off to disable IPv6 support which is annoying on IPv4 only boxes.
UseIPv6				on
# If set on you can experience a longer connection delay in many cases.
IdentLookups			off

ServerName			"Server"
ServerType			standalone
DeferWelcome			off

MultilineRFC2228		on
DefaultServer			on
ShowSymlinks			on

TimeoutNoTransfer		600
TimeoutStalled			600
TimeoutIdle			1200

DisplayLogin                    welcome.msg
DisplayChdir               	.message true
ListOptions                	"-l"

DenyFilter			\*.*/

# Use this to jail all users in their homes 
DefaultRoot			~

# Users require a valid shell listed in /etc/shells to login.
# Use this directive to release that constrain.
# RequireValidShell		off

# Port 21 is the standard FTP port.
#Port				21

# In some cases you have to specify passive ports range to by-pass
# firewall limitations. Ephemeral ports can be used for that, but
# feel free to use a more narrow range.
# PassivePorts                  49152 65534

# If your host was NATted, this option is useful in order to
# allow passive tranfers to work. You have to use your public
# address and opening the passive ports used on your firewall as well.
# MasqueradeAddress		1.2.3.4

# This is useful for masquerading address with dynamic IPs:
# refresh any configured MasqueradeAddress directives every 8 hours
<IfModule mod_dynmasq.c>
# DynMasqRefresh 28800
</IfModule>

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances			30

# Set the user and group that the server normally runs at.
User				proftpd
Group				nogroup

# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask				022  022
# Normally, we want files to be overwriteable.
AllowOverwrite			on

# Uncomment this if you are using NIS or LDAP via NSS to retrieve passwords:
# PersistentPasswd		off

# This is required to use both PAM-based authentication and local passwords
# AuthOrder			mod_auth_pam.c* mod_auth_unix.c

# Be warned: use of this directive impacts CPU average load!
# Uncomment this if you like to see progress and transfer rate with ftpwho
# in downloads. That is not needed for uploads rates.
#
# UseSendFile			off

TransferLog /var/log/proftpd/xferlog
SystemLog   /var/log/proftpd/proftpd.log

# Logging onto /var/log/lastlog is enabled but set to off by default
#UseLastlog on

# In order to keep log file dates consistent after chroot, use timezone info
# from /etc/localtime.  If this is not set, and proftpd is configured to
# chroot (e.g. DefaultRoot or <Anonymous>), it will use the non-daylight
# savings timezone regardless of whether DST is in effect.
#SetEnv TZ :/etc/localtime

<IfModule mod_quotatab.c>
QuotaEngine off
</IfModule>

<IfModule mod_ratio.c>
Ratios off
</IfModule>


# Delay engine reduces impact of the so-called Timing Attack described in
# http://www.securityfocus.com/bid/11430/discuss
# It is on by default. 
<IfModule mod_delay.c>
DelayEngine on
</IfModule>

<IfModule mod_ctrls.c>
ControlsEngine        off
ControlsMaxClients    2
ControlsLog           /var/log/proftpd/controls.log
ControlsInterval      5
ControlsSocket        /var/run/proftpd/proftpd.sock
</IfModule>

<IfModule mod_ctrls_admin.c>
AdminControlsEngine off
</IfModule>



#
# Alternative authentication frameworks
#
#Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf

#
# This is used for FTPS connections
#
#Include /etc/proftpd/tls.conf

#
# Useful to keep VirtualHost/VirtualRoot directives separated
#
#Include /etc/proftpd/virtuals.conf

# A basic anonymous configuration, no upload directories.

# <Anonymous ~ftp>
#   User				ftp
#   Group				nogroup
#   # We want clients to be able to login with "anonymous" as well as "ftp"
#   UserAlias			anonymous ftp
#   # Cosmetic changes, all files belongs to ftp user
#   DirFakeUser	on ftp
#   DirFakeGroup on ftp
# 
#   RequireValidShell		off
# 
#   # Limit the maximum number of anonymous logins
#   MaxClients			10
# 
#   # We want 'welcome.msg' displayed at login, and '.message' displayed
#   # in each newly chdired directory.
#   DisplayLogin			welcome.msg
#   DisplayChdir		.message
# 
#   # Limit WRITE everywhere in the anonymous chroot
#   <Directory *>
#     <Limit WRITE>
#       DenyAll
#     </Limit>
#   </Directory>
# 
#   # Uncomment this if you're brave.
#   # <Directory incoming>
#   #   # Umask 022 is a good standard umask to prevent new files and dirs
#   #   # (second parm) from being group and world writable.
#   #   Umask				022  022
#   #            <Limit READ WRITE>
#   #            DenyAll
#   #            </Limit>
#   #            <Limit STOR>
#   #            AllowAll
#   #            </Limit>
#   # </Directory>
# 
# </Anonymous>

# Include other custom configuration files
Include /etc/proftpd/conf.d/

sftp.conf

Code: Alles auswählen

<IfModule mod_sftp.c>
SFTPEngine on
Port 2222
SFTPLog /var/log/proftpd/sftp.log
SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/ssh/ssh_host_dsa_key
SFTPAuthMethods publickey
SFTPAuthorizedUserKeys file:/etc/proftpd/authorized_keys/%u
SFTPCompression delayed
</IfModule>
Das sollte doch eigentlich alles passen oder?
Ich hoffe mir kann von euch jeamnd helfen =)

nepos
Beiträge: 5238
Registriert: 05.01.2005 10:08:12

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von nepos » 10.02.2016 17:51:05

Du hast hier nur Ausgaben von FileZilla. TCP-Handshake scheint zu klappen, aber dann kommt wohl nix vom ProFTPD.
Hast du denn da schon mal geschaut, was der loggt?
Fuer die ersten Versuche koenntest du es ja auch erstmal mit Passwort-Authentisierung statt Public Key probieren.
Wenn das klappt, kannst du ja wieder auf PubKey gehen.

Potie
Beiträge: 20
Registriert: 13.04.2014 17:11:24

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von Potie » 10.02.2016 18:14:10

Hi Nepos,
Danke für deine Antwort,
Ich habe PW Auth. natürlich auch bereits versucht, das Ergebnis das gleiche
Hier mal die Profpd.log

Code: Alles auswählen

2016-02-10 18:06:13,980 Lukas proftpd[27245] ecto1: ProFTPD 1.3.5 (stable) (built Tue May 19 2015 11:09:58 UTC) standalone mode STARTUP
2016-02-10 18:06:37,765 Lukas proftpd[27288] ecto1 ich.t-ipconnect.de[xx.xx.xxx.xxx]): SSH2 session opened.
2016-02-10 18:06:37,810 Lukas proftpd[27288] ecto1 (ich.dip0.t-ipconnect.de[xx.xx.xxx.xxx]): SSH2 session closed.
2016-02-10 18:07:58,836 Lukas proftpd[27245] ecto1: ProFTPD killed (signal 15)
2016-02-10 18:07:58,836 Lukas proftpd[27245] ecto1: ProFTPD 1.3.5 standalone mode SHUTDOWN
2016-02-10 18:07:58,931 Lukas proftpd[27524] ecto1: ProFTPD 1.3.5 (stable) (built Tue May 19 2015 11:09:58 UTC) standalone mode STARTUP
2016-02-10 18:08:19,091 Lukas proftpd[27604] ecto1 (ich.dip0.t-ipconnect.de[xx.xx.xxx.xxx]): SSH2 session opened.
2016-02-10 18:08:19,160 Lukas proftpd[27604] ecto1 (ich.dip0.t-ipconnect.de[xx.xx.xxx.xxx]): SSH2 session close
Um 18:06 Neustart mit Pubkey, und um 18:07 mit PW Auth.
Hier auch noch die sftp.log

Code: Alles auswählen

2016-02-10 18:03:54,621 mod_sftp/0.9.9[26723]: error using DisplayLogin 'welcome.msg': Datei oder Verzeichnis nicht gefunden
2016-02-10 18:03:54,622 mod_sftp/0.9.9[26723]: sent server version 'SSH-2.0-mod_sftp/0.9.9'
2016-02-10 18:03:55,146 mod_sftp/0.9.9[26723]: disconnecting client (received EOF)
2016-02-10 18:05:02,418 mod_sftp/0.9.9[26978]: error using DisplayLogin 'welcome.msg': Datei oder Verzeichnis nicht gefunden
2016-02-10 18:05:02,453 mod_sftp/0.9.9[26978]: sent server version 'SSH-2.0-mod_sftp/0.9.9'
2016-02-10 18:05:02,491 mod_sftp/0.9.9[26978]: disconnecting client (received EOF)
2016-02-10 18:06:37,764 mod_sftp/0.9.9[27288]: error using DisplayLogin 'welcome.msg': Datei oder Verzeichnis nicht gefunden
2016-02-10 18:06:37,766 mod_sftp/0.9.9[27288]: sent server version 'SSH-2.0-mod_sftp/0.9.9'
2016-02-10 18:06:37,810 mod_sftp/0.9.9[27288]: disconnecting client (received EOF)
2016-02-10 18:08:19,090 mod_sftp/0.9.9[27604]: error using DisplayLogin 'welcome.msg': Datei oder Verzeichnis nicht gefunden
2016-02-10 18:08:19,092 mod_sftp/0.9.9[27604]: sent server version 'SSH-2.0-mod_sftp/0.9.9'
2016-02-10 18:08:19,159 mod_sftp/0.9.9[27604]: disconnecting client (received EOF)
Also hier werden nur die restarts geloggt..
Hast du noch eine Idee?

uname
Beiträge: 12072
Registriert: 03.06.2008 09:33:02

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von uname » 10.02.2016 20:30:56

Wie kann man wohl einer so sinnlosen Anwendung wie ProFTPd beibringen wie ein sftp-Server zu agieren. Das ist doch vollkommen unnütz. Der normale SSH/sftp-Server kann unter anderem auch Benutzer in eine chroot-Umgebung einsperren. Und nur einen SSH-Server für alles zu verwenden wird wohl weit sicherer sein als zusätzlich so ein komischen FTP-Server mit Port 2222 zu betreiben mit irgendeinem sftp-Plugin.

Hier nun meine Anleitung für einen Benutzer test. Es wird ein Benutzer test mit Shell /bin/false und Verzeichnis /home/test angelegt. Passwort wird vergeben. Das mit dem Key erst dann probieren wenn es mit Passwort läuft.

Anpassungen /etc/ssh/sshd_config:

Code: Alles auswählen

Subsystem sftp /usr/lib/openssh/sftp-server

Match User test
    ForceCommand internal-sftp
    ChrootDirectory /home/test
    X11Forwarding no
    AllowTcpForwarding no

Code: Alles auswählen

service ssh restart
Nun ist es so, dass /home/test der Ordner / in der chroot-Umgebung ist. Diese muss root:root gehören und der Rest (also /home/test) muss in der chroot-Umgebung neu zusammengebaut werden:

Code: Alles auswählen

chown root:root /home/test
mkdir -p /home/test/home/test
chown test:test /home/test/home/test
chmod 755 /home/test/home/test
Der Benutzer denkt er ist in /home/test, ist aber eigentlich in /home/test/home/test:

Code: Alles auswählen

sftp test@localhost
test@localhost's password: 
Connected to localhost.
sftp> pwd
Remote working directory: /home/test
sftp> cd ..
sftp> pwd
Remote working directory: /home
sftp> ls
test  
sftp> 
Port ist weiterhin 22. Ich denke ich habe alle Klarheiten beseitigt. ProFTPd kannst du anschließend runterwerfen. Die aufgeführte Anleitung war ja ganz nett nur leider vollkommen am Problem vorbei. Sie erscheint dann sinnvoll, wenn du den SSH-Server nicht ändern darfst oder willst. Natürlich gehe ich davon aus, dass du einen SSH-Server bereits nutzt. Vielleicht hast du das sftp-Subsystem auch bereits aktiviert.

Nachtrag SSH-Key:

Code: Alles auswählen

mkdir /home/test/.ssh
cp irgendeine-id_rsa.pub /home/test/.ssh/authorized_keys

Potie
Beiträge: 20
Registriert: 13.04.2014 17:11:24

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von Potie » 10.02.2016 21:12:35

Vielen Dank für diese sehr ausführlich und sehr gut erklärte Anleitung, funktioniert alles auf Anhieb und wunderbar =)

Den Match User Block habe ich nach ganz unten geschoben.
Hat gemeckert wegen UsePAM

Code: Alles auswählen

 ✓ root @ Lukas  ~  $ service ssh restart
/etc/ssh/sshd_config line 93: Directive 'UsePAM' is not allowed within a Match block
Wieso einfach wenn es auch kompliziert geht :roll:
Danke nochmal

Potie
Beiträge: 20
Registriert: 13.04.2014 17:11:24

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von Potie » 13.02.2016 16:13:45

Hallo,
Kann es sein das für andere Benutzer die PubkeyAuthentication extra aktiviert werden muss?
Hab einen Benutzer (In unserem Fall "test" erstellt)
mit su test den User gewechselt, einen neuen Key erstellt, ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa
Den id_rsa als ppk auf dem Rechner gespeichert, will ich jetz via Putty, Filezilla etc. connecten
Immer der Fehler: "Disconnected: No supported authentication methods available (server sent: publickey)

schwedenmann
Beiträge: 5528
Registriert: 30.12.2004 15:31:07
Wohnort: Wegberg

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von schwedenmann » 13.02.2016 18:17:08

Hallo



Afaik muß man doch nur für den Server ein ssl-Certifikat erstellen, dann kann jeder user per filezilla, gftp sich over ssh mit dem ftpo-Server verbinden. So habe ich das jedenfalls für pureftpd gemacht (wobei das keine vuser sind, sondern reale user auf dem ftp-server, aber nat. gechrootet).

mfg
schwedenmann

uname
Beiträge: 12072
Registriert: 03.06.2008 09:33:02

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von uname » 14.02.2016 08:42:11

FTP und somit ftps (ftp tls/ssl) war kein Thema mehr. Denke das Problem liegt an den Putty-SSH-Keys also ein Windows-Problem.

nepos
Beiträge: 5238
Registriert: 05.01.2005 10:08:12

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von nepos » 15.02.2016 17:53:31

Ja, denke da fehlt das Konvertieren des Keys mittels puttygen.
@Potie: PuTTY nutzt ein anderes Format fuer die Keys als es OpenSSH tut, daher musst du den Key erstmal noch umwandeln, bevor du den als ppk-File speicherst.

@uname: Mein erster Gedanke war hier: Ah, mal wieder jemand, der SFTP und FTPS verwechselt. Mein zweiter: oh mein Gott, SFTP im ProFTPD ;)

Potie
Beiträge: 20
Registriert: 13.04.2014 17:11:24

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von Potie » 15.02.2016 19:37:02

Hi,
Nene kein Windows Fehler, bin auf Linux unterwegs, Putty hatte ich nur zum Testen des Schlüsselpaares benutzt.
Aber der Fehler ist sehr Peinlich :roll:
Die id_rsa.pub musste natürlich in authorized_keys umbenannt werden.
Jetzt funktioniert der Login mit dem Pubkey.
Danke für eure Hilfe :)

uname
Beiträge: 12072
Registriert: 03.06.2008 09:33:02

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von uname » 15.02.2016 19:51:07

Du hast Debianputty unter Debian genutzt. Nicht wirklich, oder?

Potie
Beiträge: 20
Registriert: 13.04.2014 17:11:24

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von Potie » 15.02.2016 19:59:02

Putty unter Windows zum testen,
Terminal unter Mint, auf dem Server läuft Debian

Potie
Beiträge: 20
Registriert: 13.04.2014 17:11:24

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von Potie » 15.02.2016 20:31:52

Kommando zurück, alles läuft
Zuletzt geändert von Potie am 15.02.2016 21:06:47, insgesamt 1-mal geändert.

schwedenmann
Beiträge: 5528
Registriert: 30.12.2004 15:31:07
Wohnort: Wegberg

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von schwedenmann » 15.02.2016 21:00:05

Hallo


Ist das jetzt ein Systemuser auf dem ftp-Server-System, oder ein vuser ?

mfg
schwedenmann

uname
Beiträge: 12072
Registriert: 03.06.2008 09:33:02

Re: Keine Verbindung via SFTP mit ProFTPd zum Server möglich

Beitrag von uname » 16.02.2016 08:07:08

Er nutzt kein ftp-Server, sondern das sftp-Subsystem von SSH. Es handelt sich um einen Restricted-User mit der Shell /bin/false und der Einschränkung auf eine chroot-Umgebung für sftp, deren Konfiguration in /etc/ssh/sshd_config erfolgte. ProFTPd hat er hoffentlch bereits deinstalliert.

Antworten