[Solucionado] SSH y SFTP

Iniciado por venadHD, 18 Febrero 2015, 20:30 PM

0 Miembros y 1 Visitante están viendo este tema.

venadHD

Resulta que instale pure-ftpd y algunos que otras dependencias de el, lo desinstale hace unas horas, y todos los usuarios que tenia dejaron de funcionar (Al logear por SFTP, excepto, 1, pondre un ejemplo)

root
user1
user2
user3

root puede loggearse
user1 puede loggearse
user2 NO puede loggearse
user3 NO puede loggearse

La configuracion era la siguiente para estos usuarios

#Match group mtahost
 #  ChrootDirectory %h
   #X11Forwarding no
   #AllowTcpForwarding no
   #ForceCommand internal-sftp


(Sin comentar, obvio)
Solo funciona un usuario, al intentar loggear con ellos, me salta el siguiente error:

Registro de autenticación (usa el registro de sesión para más detalles):
Usando el nombre de usuario "user2".

Autenticación fallida!
El servidor ha rechazado la conexión SFTP, pero escucha las conexiones FTP.

desea utilizar el protocolo FTP en lugar de SFTP? Prefiera el uso de cifrado (SFTP).


Ya solo activando el ChrootDirectory, ya me tira error, por que puede ser?

Registro de sesion

. 2015-02-18 20:36:43.203 --------------------------------------------------------------------------
. 2015-02-18 20:36:43.203 WinSCP Version 5.5.6 (compilación 4746) (OS 5.1.2600 Service Pack 3 - Microsoft Windows XP)
. 2015-02-18 20:36:43.203 Configuration: HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\
. 2015-02-18 20:36:43.203 Local account: Andrelyoko\Andre
. 2015-02-18 20:36:43.203 Working directory: C:\Documents and Settings\Andre\Escritorio
. 2015-02-18 20:36:43.203 Process ID: 1376
. 2015-02-18 20:36:43.203 Command-line: "C:\Archivos de programa\WinSCP\WinSCP.exe"
. 2015-02-18 20:36:43.203 Time zone: Current: GMT+1, Standard: GMT+1 (Hora estándar romance), DST: GMT+2 (Hora de verano romance), DST Start: 29/03/2015, DST End: 25/10/2015
. 2015-02-18 20:36:43.203 Login time: miércoles, 18 de febrero de 2015 20:36:43
. 2015-02-18 20:36:43.203 --------------------------------------------------------------------------
. 2015-02-18 20:36:43.203 Session name: humber (Site)
. 2015-02-18 20:36:43.203 Host name: 5.175.139.216 (Port: 22)
. 2015-02-18 20:36:43.203 User name: humber (Password: Yes, Key file: No)
. 2015-02-18 20:36:43.203 Tunnel: No
. 2015-02-18 20:36:43.203 Transfer Protocol: SFTP (SCP)
. 2015-02-18 20:36:43.203 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2015-02-18 20:36:43.203 Proxy: none
. 2015-02-18 20:36:43.203 Send buffer: 262144
. 2015-02-18 20:36:43.203 SSH protocol version: 2; Compression: No
. 2015-02-18 20:36:43.203 Bypass authentication: No
. 2015-02-18 20:36:43.203 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: Yes
. 2015-02-18 20:36:43.203 GSSAPI: Forwarding: No; Server realm:
. 2015-02-18 20:36:43.203 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2015-02-18 20:36:43.203 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2015-02-18 20:36:43.203 Simple channel: Yes
. 2015-02-18 20:36:43.203 Return code variable: Autodetect; Lookup user groups: A
. 2015-02-18 20:36:43.203 Shell: default
. 2015-02-18 20:36:43.203 EOL: 0, UTF: 2
. 2015-02-18 20:36:43.203 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2015-02-18 20:36:43.203 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2015-02-18 20:36:43.203 SFTP Bugs: A,A
. 2015-02-18 20:36:43.203 SFTP Server: default
. 2015-02-18 20:36:43.203 Local directory: C:\Documents and Settings\Andre\Mis documentos, Remote directory: /home/humber, Update: Yes, Cache: Yes
. 2015-02-18 20:36:43.203 Cache directory changes: Yes, Permanent: Yes
. 2015-02-18 20:36:43.203 DST mode: 0; Timezone offset: 0h 0m
. 2015-02-18 20:36:43.203 --------------------------------------------------------------------------
. 2015-02-18 20:36:43.328 Looking up host "5.175.139.216"
. 2015-02-18 20:36:43.328 Connecting to 5.175.139.216 port 22
. 2015-02-18 20:36:43.406 Selecting events 63 for socket 944
. 2015-02-18 20:36:43.421 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:43.421 Looking for incoming data
. 2015-02-18 20:36:43.421 Looking for network events
. 2015-02-18 20:36:43.421 Detected network event
. 2015-02-18 20:36:43.421 Enumerating network events for socket 944
. 2015-02-18 20:36:43.421 Enumerated 18 network events making 18 cumulative events for socket 944
. 2015-02-18 20:36:43.421 Handling network write event on socket 944 with error 0
. 2015-02-18 20:36:43.421 Handling network connect event on socket 944 with error 0
. 2015-02-18 20:36:43.421 Looking for network events
. 2015-02-18 20:36:43.500 Detected network event
. 2015-02-18 20:36:43.500 Enumerating network events for socket 944
. 2015-02-18 20:36:43.500 Enumerated 1 network events making 1 cumulative events for socket 944
. 2015-02-18 20:36:43.500 Handling network read event on socket 944 with error 0
. 2015-02-18 20:36:43.500 Server version: SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2
. 2015-02-18 20:36:43.500 Using SSH protocol version 2
. 2015-02-18 20:36:43.500 We claim version: SSH-2.0-WinSCP_release_5.5.6
. 2015-02-18 20:36:43.500 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:43.500 Looking for incoming data
. 2015-02-18 20:36:43.500 Looking for network events
. 2015-02-18 20:36:43.578 Detected network event
. 2015-02-18 20:36:43.578 Enumerating network events for socket 944
. 2015-02-18 20:36:43.578 Enumerated 1 network events making 1 cumulative events for socket 944
. 2015-02-18 20:36:43.578 Handling network read event on socket 944 with error 0
. 2015-02-18 20:36:43.578 Doing Diffie-Hellman group exchange
. 2015-02-18 20:36:43.578 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:43.578 Looking for incoming data
. 2015-02-18 20:36:43.578 Looking for network events
. 2015-02-18 20:36:43.781 Detected network event
. 2015-02-18 20:36:43.781 Enumerating network events for socket 944
. 2015-02-18 20:36:43.781 Enumerated 1 network events making 1 cumulative events for socket 944
. 2015-02-18 20:36:43.781 Handling network read event on socket 944 with error 0
. 2015-02-18 20:36:43.796 Doing Diffie-Hellman key exchange with hash SHA-256
. 2015-02-18 20:36:44.625 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:44.625 Looking for incoming data
. 2015-02-18 20:36:44.625 Looking for network events
. 2015-02-18 20:36:44.828 Detected network event
. 2015-02-18 20:36:44.828 Enumerating network events for socket 944
. 2015-02-18 20:36:44.828 Enumerated 1 network events making 1 cumulative events for socket 944
. 2015-02-18 20:36:44.828 Handling network read event on socket 944 with error 0
. 2015-02-18 20:36:46.031 Verifying host key rsa2 0x10001,0xb7f3153dc5be4cf5 00a0cfd67bc052be d54201b7bba21598 60d93dd3ce341e3e df532964369b09f9 9e99aee3f717c78b d22b31150b1684d9 c6b73cfbf7770fb7 16a87acc5364e61d 180b5c71f26f896b ac8cfa54bb7a2c2f fcd5994017c9a935 9dc758e6f553513d dacbe915cb256b44 5258f8e32fc5f9c0 e58c51249115403d ed4663eb180de029 1b167f5dbc81f85f dd3a76ad4a29ca8c fee3f07497aa0ab2 e989f604c18c4510 eb7c97a5b8f7ede8 6015937b1e7600ad 6c0909492f7bc89d ea300edea6dc59bc a449d6ece647be5f 0a9f260e66573277 06116bcb3c9013f9 c6d187145556c950 fa9fb676723483d8 410d4e72db8be0a1 955379207b3f56db  with fingerprint ssh-rsa 2048 b7:12:16:1c:c3:de:ea:cb:f8:1a:1b:5e:66:3e:9e:fb
. 2015-02-18 20:36:46.046 Host key matches cached key
. 2015-02-18 20:36:46.046 Selecting events 63 for socket 944
. 2015-02-18 20:36:46.046 Host key fingerprint is:
. 2015-02-18 20:36:46.046 ssh-rsa 2048 b7:12:16:1c:c3:de:ea:cb:f8:1a:1b:5e:66:3e:9e:fb
. 2015-02-18 20:36:46.046 Initialised AES-256 SDCTR client->server encryption
. 2015-02-18 20:36:46.046 Initialised HMAC-SHA-256 client->server MAC algorithm
. 2015-02-18 20:36:46.046 Initialised AES-256 SDCTR server->client encryption
. 2015-02-18 20:36:46.046 Initialised HMAC-SHA-256 server->client MAC algorithm
. 2015-02-18 20:36:46.046 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:46.046 Looking for incoming data
. 2015-02-18 20:36:46.046 Looking for network events
. 2015-02-18 20:36:46.218 Detected network event
. 2015-02-18 20:36:46.218 Enumerating network events for socket 944
. 2015-02-18 20:36:46.218 Enumerated 1 network events making 1 cumulative events for socket 944
. 2015-02-18 20:36:46.218 Handling network read event on socket 944 with error 0
! 2015-02-18 20:36:46.218 Using username "humber".
. 2015-02-18 20:36:46.250 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:46.250 Looking for incoming data
. 2015-02-18 20:36:46.250 Looking for network events
. 2015-02-18 20:36:46.359 Detected network event
. 2015-02-18 20:36:46.359 Enumerating network events for socket 944
. 2015-02-18 20:36:46.359 Enumerated 1 network events making 1 cumulative events for socket 944
. 2015-02-18 20:36:46.359 Handling network read event on socket 944 with error 0
. 2015-02-18 20:36:46.359 Prompt (7, SSH password, , &Contraseña)
. 2015-02-18 20:36:46.359 Using stored password.
. 2015-02-18 20:36:46.359 Sent password
. 2015-02-18 20:36:46.359 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:46.359 Looking for incoming data
. 2015-02-18 20:36:46.359 Looking for network events
. 2015-02-18 20:36:46.531 Detected network event
. 2015-02-18 20:36:46.531 Enumerating network events for socket 944
. 2015-02-18 20:36:46.531 Enumerated 1 network events making 1 cumulative events for socket 944
. 2015-02-18 20:36:46.531 Handling network read event on socket 944 with error 0
. 2015-02-18 20:36:46.531 Access granted
. 2015-02-18 20:36:46.531 Opening session as main channel
. 2015-02-18 20:36:46.531 Waiting for the server to continue with the initialization
. 2015-02-18 20:36:46.531 Looking for incoming data
. 2015-02-18 20:36:46.531 Looking for network events
. 2015-02-18 20:36:46.531 Detected network event
. 2015-02-18 20:36:46.531 Enumerating network events for socket 944
. 2015-02-18 20:36:46.531 Enumerated 32 network events making 32 cumulative events for socket 944
. 2015-02-18 20:36:46.531 Handling network close event on socket 944 with error 0
. 2015-02-18 20:36:46.531 Selecting events 0 for socket 944
. 2015-02-18 20:36:46.531 Server unexpectedly closed network connection
. 2015-02-18 20:36:46.531 Knocking FTP port.
. 2015-02-18 20:36:47.640 FTP port opened, will suggest using FTP protocol.
* 2015-02-18 20:36:47.671 (EFatal) El servidor cerró inesperadamente la conexión
* 2015-02-18 20:36:47.671 Registro de autenticación (usa el registro de sesión para más detalles):
* 2015-02-18 20:36:47.671 Usando el nombre de usuario "humber".
* 2015-02-18 20:36:47.671
* 2015-02-18 20:36:47.671 Autenticación fallida!
* 2015-02-18 20:36:47.671 El servidor ha rechazado la conexión SFTP, pero escucha las conexiones FTP.
* 2015-02-18 20:36:47.671
* 2015-02-18 20:36:47.671  desea utilizar el protocolo FTP en lugar de SFTP? Prefiera el uso de cifrado (SFTP).

venadHD

Y si creo un nuevo usuario, pasa lo mismo

kondrag_X1


venadHD

en /var/log no existe ningun log relacionado con SFTP o SSH (Estoy usando debian 7 y OpenSSH)

MinusFour

Asegurate que:

1) Tus usuarios tengan un directorio home.
2) Este habilitado internal-sftp:


Subsystem sftp internal-sftp


Tambien... acerca de ChrootDirectory:

Citar
All components of  the  path‐name  must  be root-owned directories that are not writable by any other user or group.

3) Que tus usuarios pertenezcan al grupo mtahost.

venadHD

Si, si, esta todo perfecto, al cabo de un tiempo fallo, es decir, funcionaba a la perfeccion y derrepente falló, el archivo está bien y pertenecen al grupo, los directorios bajo root, tal cual lo pusiste y aun asi error de autentificacion

MinusFour

#6
Cita de: venadHD en 19 Febrero 2015, 02:37 AM
Si, si, esta todo perfecto, al cabo de un tiempo fallo, es decir, funcionaba a la perfeccion y derrepente falló, el archivo está bien y pertenecen al grupo, los directorios bajo root, tal cual lo pusiste y aun asi error de autentificacion

Creo que los atentos de autentificacion deben estar en:


/var/log/auth.log


Revisa si hay algo sospechoso ahi.

Edit: Para activar los logs de SFTP en OpenSSH, tienes que modificar sshd_config:

Subsystem   sftp    internal-sftp -f AUTH -l INFO

Y deberian aparecer los mensajes en /var/log/messages.

venadHD

Acabé por instalar una servidor FTP. Denege el acceso a SFTP (Por si acaso surge la magia y se arregla solo (No es la primera vez que me pasa))

Archivo /var/log/auth.log

No, no se me ha olvidado pegar nada.