[gelöst] Probleme mit WinSCP und SFTP

Probleme mit Samba, NFS, FTP und Co.
Antworten
brain1
Beiträge: 6
Registriert: 13.06.2012 12:58:48

[gelöst] Probleme mit WinSCP und SFTP

Beitrag von brain1 » 13.06.2012 13:08:02

Hallo zusammen,

erst einmal Hallo an Alle.

Ich habe folgendes Problem:

In einer VM habe ich ein Debian-Squeeze aufgesetzt (inkl OpenSSH-Server). Alles soweit wunderbar. Auf meinem Windows-Rechner habe ich WinSCP installiert. Jetzt habe ich allerdings seit Kurzem das Problem, dass ich mich mit "root" nicht mehr per SFTP an dem Debian-System anmelden kann.

Folgende Fehlermeldung bringt mir WinSCP:

"Kann das SFTP nicht initialisieren. Läuft auf dem entfernten Rechner ein SFTP Server Programm?"

Das Seltsame ist, dass ich das Problem nur mit dem "root"-Benutzer habe. Normale Standartbenutzer funktionieren mit WinSCP einwandfrei. Schalte ich das Protokoll auf SCP um, kann sich auch der "root"-Benutzer verbinden. Nach der frischen Installation funktionierte auch "root" mit SFTP. Erst nach einer gewissen Zeit nicht mehr. Ich habe noch weitere Systeme mit einer identischen Debian-Installation laufen, bei denen solche Probleme nicht auftreten.

Im Internet hab ich auch schon alle möglichen Tipps ausprobiert, aber nichts hat mir weiterhelfen können und hoffe nun auf Hilfe von Euch.

Solltet Ihr eine Idee dazu haben, wäre ich Euch sehr dankbar.

Vielen Danks schon mal im Voraus

Brain1
Zuletzt geändert von brain1 am 19.06.2012 10:11:05, insgesamt 1-mal geändert.

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

Re: Probleme mit WinSCP und SFTP

Beitrag von uname » 13.06.2012 13:19:04

Der sftp-Zugang wird über /etc/ssh/sshd_config gesteuert und dort auch eingeschränkt. Musst dort mal schauen ob root berechtigt ist. Schau auch noch im Ordner /etc/pam.d, da das ganze Zeug über PAM gesteuert wird, wobei kein Unterschied zwischen SSH und sftp dort gemacht wird.
Generell kenne ich das Problem eher umgekehrt, dass SFTP funktioniert und scp nicht. Das liegt dann eher an der jeweiligen Shell.

brain1
Beiträge: 6
Registriert: 13.06.2012 12:58:48

Re: Probleme mit WinSCP und SFTP

Beitrag von brain1 » 13.06.2012 14:01:34

Danke für die schnelle Antwort.

Mit putty kann ich mich auch als "root" verbinden.

Die "sshd_config" hab ich auch mit den anderen System verlichen. Diese Dateien sind identisch.

Hier einfach mal die Konfig:

---------------------------------------------------------------------------------------------------------------------------------------------------
# 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
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

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

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
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 yes
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 /usr/lib/openssh/sftp-server

# 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 without-password".
# 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

---------------------------------------------------------------------------------------------------------------------------------------------------


Mir gehen echt die Ideen aus. Wird vielleicht irgendwo was gecached.

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

Re: Probleme mit WinSCP und SFTP

Beitrag von uname » 13.06.2012 14:05:38

Führe mal eine Anmeldung durch und poste den Auszug aus /var/log/auth.log.

brain1
Beiträge: 6
Registriert: 13.06.2012 12:58:48

Re: Probleme mit WinSCP und SFTP

Beitrag von brain1 » 13.06.2012 14:25:01

Hier der Auszug:

--------------------------------------------------------
Jun 13 14:20:38 server sshd[26090]: Accepted password for root from 192.168.0.79 port 51541 ssh2
Jun 13 14:20:38 server sshd[26090]: pam_unix(sshd:session): session opened for user root by (uid=0)
Jun 13 14:20:38 server sshd[26090]: subsystem request for sftp
Jun 13 14:20:38 server sshd[26090]: pam_unix(sshd:session): session closed for user root
Jun 13 14:20:48 server sshd[26093]: Accepted password for root from 192.168.0.79 port 51542 ssh2
Jun 13 14:20:48 server sshd[26093]: pam_unix(sshd:session): session opened for user root by (uid=0)
Jun 13 14:20:48 server sshd[26093]: subsystem request for sftp
Jun 13 14:20:48 server sshd[26093]: pam_unix(sshd:session): session closed for user root
Jun 13 14:20:59 server sshd[26096]: Accepted password for root from 192.168.0.79 port 51545 ssh2
Jun 13 14:20:59 server sshd[26096]: pam_unix(sshd:session): session opened for user root by (uid=0)
Jun 13 14:20:59 server sshd[26096]: subsystem request for sftp
Jun 13 14:20:59 server sshd[26096]: pam_unix(sshd:session): session closed for user root
Jun 13 14:21:10 server sshd[26101]: Accepted password for root from 192.168.0.79 port 51547 ssh2
Jun 13 14:21:10 server sshd[26101]: pam_unix(sshd:session): session opened for user root by (uid=0)
Jun 13 14:21:10 server sshd[26101]: subsystem request for sftp
Jun 13 14:21:10 server sshd[26101]: pam_unix(sshd:session): session closed for user root
Jun 13 14:21:20 server sshd[26104]: Accepted password for root from 192.168.0.79 port 51548 ssh2
Jun 13 14:21:20 server sshd[26104]: pam_unix(sshd:session): session opened for user root by (uid=0)
Jun 13 14:21:20 server sshd[26104]: subsystem request for sftp
Jun 13 14:21:20 server sshd[26104]: pam_unix(sshd:session): session closed for user root

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

Re: Probleme mit WinSCP und SFTP

Beitrag von uname » 13.06.2012 15:23:17

Leider fällt mir nur noch ein Versuch ein. Installiere mal Debianstrace und starte in einem am besten leeren Ordner natürlich als "root":

Code: Alles auswählen

strace -ff -o out.txt -p <prozess-id>
Die Prozess-ID ist der Serverprozess, siehe "ps -ef" bzw. PID-File:

Code: Alles auswählen

root     <prozess-id>    1  0 15:17 ?        00:00:00 /usr/sbin/sshd
cat /var/run/sshd.pid
Beim Anmelden über sftp sollten nun ein paar Dateien out.txt.<prozess-id> für mehrere Prozesse und Unterprozesse erzeugt werden. Dort ist erkennbar welche Dateien gelesen werden. Interessant wird es wohl da wo das Passwort eingegeben wird. Kannst ja mal suchen, liegt natürlich im Klartext vor. Auch gibt es etwas später bzw. in den aufrufenden Prozessen vielleicht irgendwelche Informationen.

brain1
Beiträge: 6
Registriert: 13.06.2012 12:58:48

Re: Probleme mit WinSCP und SFTP

Beitrag von brain1 » 15.06.2012 12:12:27

So, ich hab das jetzt mal getracet:

Leider werde ich da auch nicht so ganz schlau draus:

Hier mal ein trace-Ausschnitt:

---------------------------------------------------------------------------------
29391 write(4, "\0\0\0\PASSWORD", 22) = 22
29390 read(6, <unfinished ...>
29391 read(4, <unfinished ...>
29390 <... read resumed> "\v\0\0\0\PASSWORD", 23) = 23
29390 getuid() = 0
29390 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4
29390 lseek(4, 0, SEEK_CUR) = 0
29390 fstat(4, {st_mode=S_IFREG|0644, st_size=1298, ...}) = 0
29390 mmap(NULL, 1298, PROT_READ, MAP_SHARED, 4, 0) = 0x7f5696368000
29390 lseek(4, 1298, SEEK_SET) = 1298
29390 munmap(0x7f5696368000, 1298) = 0
29390 close(4) = 0
29390 open("/etc/shadow", O_RDONLY|O_CLOEXEC) = 4
29390 lseek(4, 0, SEEK_CUR) = 0
29390 fstat(4, {st_mode=S_IFREG|0640, st_size=1080, ...}) = 0
29390 mmap(NULL, 1080, PROT_READ, MAP_SHARED, 4, 0) = 0x7f5696368000
29390 lseek(4, 1080, SEEK_SET) = 1080
29390 munmap(0x7f5696368000, 1080) = 0
29390 close(4) = 0
29390 mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f56961e8000
29390 munmap(0x7f56961e8000, 135168) = 0
29390 write(6, "\0\0\0\5\f", 5 <unfinished ...>
29391 <... read resumed> "\0\0\0\5", 4) = 4
29390 <... write resumed> ) = 5
29391 read(4, <unfinished ...>
29390 write(6, "\0\0\0\1", 4 <unfinished ...>
29391 <... read resumed> "\f\0\0\0\1", 5) = 5
29390 <... write resumed> ) = 4
29391 write(4, "\0\0\0\0013", 5 <unfinished ...>
29390 read(6, <unfinished ...>
29391 <... write resumed> ) = 5
29391 read(4, <unfinished ...>
29390 <... read resumed> "\0\0\0\1", 4) = 4
29390 read(6, "3", 1) = 1
29390 open("/etc/nologin", O_RDONLY) = -1 ENOENT (No such file or directory)
29390 getuid() = 0
29390 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4
29390 lseek(4, 0, SEEK_CUR) = 0
29390 fstat(4, {st_mode=S_IFREG|0644, st_size=1298, ...}) = 0
29390 mmap(NULL, 1298, PROT_READ, MAP_SHARED, 4, 0) = 0x7f5696208000
29390 lseek(4, 1298, SEEK_SET) = 1298
29390 munmap(0x7f5696208000, 1298) = 0
29390 close(4) = 0
29390 open("/etc/shadow", O_RDONLY|O_CLOEXEC) = 4
29390 lseek(4, 0, SEEK_CUR) = 0
29390 fstat(4, {st_mode=S_IFREG|0640, st_size=1080, ...}) = 0
29390 mmap(NULL, 1080, PROT_READ, MAP_SHARED, 4, 0) = 0x7f5696208000
29390 lseek(4, 1080, SEEK_SET) = 1080
29390 munmap(0x7f5696208000, 1080) = 0
29390 close(4) = 0
29390 write(6, "\0\0\0\t4", 5 <unfinished ...>
29391 <... read resumed> "\0\0\0\t", 4) = 4
29390 <... write resumed> ) = 5
29391 read(4, <unfinished ...>
29390 write(6, "\0\0\0\1\0\0\0\0", 8 <unfinished ...>
29391 <... read resumed> "4", 9) = 1
29390 <... write resumed> ) = 8
29391 read(4, "\0\0\0\1\0\0\0\0", 8) = 8
29391 write(3, ")[\"\252\320Z\352\343\22:\344)7$\361\16k[u6\372-\206\10P\3660\271\304]\310l"..., 36) = 36
29391 write(4, "\0\0\6\236\31", 5) = 5
29391 write(4, "\0\0\0\24\364zE,\357\333\fH\257]w\363\262bs\364\256M\303M\0\0\0 \0\0\0\1"..., 1693 <unfinished ...>
29390 open("/etc/localtime", O_RDONLY <unfinished ...>
29391 <... write resumed> ) = 1693
29390 <... open resumed> ) = 4
29391 exit_group(0) = ?
29390 fstat(4, {st_mode=S_IFREG|0644, st_size=2309, ...}) = 0
29390 --- SIGCHLD (Child exited) @ 0 (0) ---
29390 fstat(4, {st_mode=S_IFREG|0644, st_size=2309, ...}) = 0
29390 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5696208000
29390 read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\10\0\0\0\0"..., 4096) = 2309
29390 lseek(4, -1467, SEEK_CUR) = 842
29390 read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0\0\t\0\0\0\0"..., 4096) = 1467
29390 close(4) = 0
29390 munmap(0x7f5696208000, 4096) = 0
29390 socket(PF_FILE, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 4
29390 connect(4, {sa_family=AF_FILE, path="/dev/log"}, 110) = 0
29390 sendto(4, "<38>Jun 14 16:06:10 sshd[29390]:"..., 93, MSG_NOSIGNAL, NULL, 0) = 93
29390 close(4) = 0
29390 read(6, "\0\0\6\236", 4) = 4
29390 read(6, "\31\0\0\0\24\364zE,\357\333\fH\257]w\363\262bs\364\256M\303M\0\0\0 \0\0\0"..., 1694) = 1694
29390 close(6) = 0
29390 mmap(NULL, 1310720, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) = 0x7f5691ebb000
29390 munmap(0x7f5696349000, 65536) = 0
29390 wait4(29391, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 29391
29390 alarm(0) = 115
29390 rt_sigaction(SIGALRM, NULL, {0x7f569637a370, [], SA_RESTORER|SA_INTERRUPT, 0x7f56946f9230}, 8) = 0
29390 rt_sigaction(SIGALRM, {SIG_DFL, [], SA_RESTORER|SA_INTERRUPT, 0x7f56946f9230}, NULL, 8) = 0
29390 close(5) = 0
22082 <... select resumed> ) = 1 (in [6])
29390 open("/etc/security/pam_env.conf", O_RDONLY <unfinished ...>
22082 close(6 <unfinished ...>
29390 <... open resumed> ) = 4
22082 <... close resumed> ) = 0
29390 fstat(4, <unfinished ...>
22082 select(7, [3 4], NULL, NULL, NULL <unfinished ...>
29390 <... fstat resumed> {st_mode=S_IFREG|0644, st_size=2980, ...}) = 0
29390 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5696368000
29390 read(4, "#\n# This is the configuration fi"..., 4096) = 2980
29390 read(4, "", 4096) = 0
29390 close(4) = 0
29390 munmap(0x7f5696368000, 4096) = 0
29390 open("/etc/environment", O_RDONLY) = 4
29390 fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
29390 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5696368000
29390 read(4, "", 4096) = 0
29390 close(4) = 0
29390 munmap(0x7f5696368000, 4096) = 0
29390 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4
29390 lseek(4, 0, SEEK_CUR) = 0
29390 fstat(4, {st_mode=S_IFREG|0644, st_size=1298, ...}) = 0
29390 mmap(NULL, 1298, PROT_READ, MAP_SHARED, 4, 0) = 0x7f5696368000
29390 lseek(4, 1298, SEEK_SET) = 1298

--------------------------------------------------------------------------------------------------

Vielleicht hat ja noch jemand eine Idee.

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

Re: Probleme mit WinSCP und SFTP

Beitrag von uname » 15.06.2012 12:51:46

Eine Idee habe ich nicht. Aber es waren eigentlich mehrere Dateien, für jeden Prozess eine.

Du könntest aber noch mal die Option "-v" versuchen, um mehr Loginformationen zu erhalten. Solltest du keinen zweiten Rechner haben kannst du

Code: Alles auswählen

sftp -v user@localhost

versuchen. Poste die Ausgaben.

brain1
Beiträge: 6
Registriert: 13.06.2012 12:58:48

Re: Probleme mit WinSCP und SFTP

Beitrag von brain1 » 15.06.2012 13:30:21

Hier der Auszug:

sftp -v root@localhost
OpenSSH_5.5p1 Debian-6+squeeze2, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze2
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr 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 'localhost' is known and matches the RSA host key.
debug1: Found key in /root/.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: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
root@localhost's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = de_DE.UTF-8
debug1: Sending subsystem: sftp
debug1: client_input_channel_req: channel 0 rtype exit-signal reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 1528, received 1960 bytes, in 0.0 seconds
Bytes per second: sent 750192.7, received 962289.1
debug1: Exit status -1
Connection closed

brain1
Beiträge: 6
Registriert: 13.06.2012 12:58:48

Re: Probleme mit WinSCP und SFTP

Beitrag von brain1 » 19.06.2012 10:10:42

Oh man, ich hab's gefunden.

Ich hab mir überlegt, wenn es mit anderen Benutzern geht und nur mit dem root nicht, dann muss es was mit der rootspeziefischen Konfiguration zu tun haben.

Und tatsächlich. Die Datei /root/.bashrc sah wie folgt aus:

---------------------------------------------
# ~/.bashrc: executed by bash(1) for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval "`dircolors`"
# alias ls='ls $LS_OPTIONS'
# alias ll='ls $LS_OPTIONS -l'
# alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'

. ~/.utf8

---------------------------------------------------------------------------------------------------------

Den letzten EIntrag mit "utf8" habe ich jetzt einfach mal auskommentiert und siehe da, alles funktioniert wieder einwandfrei.

Vielen Dank für Eure Mithilfe

Cae
Beiträge: 6349
Registriert: 17.07.2011 23:36:39
Wohnort: 2130706433

Re: Probleme mit WinSCP und SFTP

Beitrag von Cae » 19.06.2012 22:44:27

brain1 hat geschrieben:

Code: Alles auswählen

. ~/.utf8
Kannst du diese Datei mal posten?

Code: Alles auswählen

# wc -l ~/.utf8 # Zeilenanzahl. Falls >30, die Datei nach NoPaste [1] hochladen
# cat ~/.utf8
Gruß Cae

[1] pastebin.php
If universal surveillance were the answer, lots of us would have moved to the former East Germany. If surveillance cameras were the answer, camera-happy London, with something like 500,000 of them at a cost of $700 million, would be the safest city on the planet.

—Bruce Schneier

Antworten