Skocz do zawartości

ITstaff

Użytkownicy
  • Zawartość

    6
  • Rejestracja

  • Ostatnio

Posty napisane przez ITstaff


  1. Słabo opisałeś w pierwszym poście, co tak naprawdę chcesz osiągnąć, ale po konfiguracji wnioskuje iż chcesz dać użytkownikowi dostęp jedynie do SFTP i tam go 'zamknąć w jego katalogu domowym'.

     

    Cały korzeń w którym chcesz zamknąć jak już wspomniał Archi musi być w posiadaniu roota

     

    Proponował bym w takim wypadku takie rozwiązanie:

    # Przygotowanie użytkownika i grupy, kolejnych użytkowników będziesz dodawał do sftp-only:
    adduser sftp01
    passwd sftp01
    groupadd sftp-only
    usermod -aG sftp-only sftp01
    usermod -d /sftp01 -s /sbin/nologin sftp01
    
    mkdir -p /sftp/sftp01/sftp01
    chown -R root:root /sftp
    chown sftp01:sftp01 /sftp/sftp01/sftp01/
    

    Podmień config w (bazowałem na Twoim, dodałem linie od # SFTP # do końca): /etc/ssh/sshd_config

    # 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
    #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_*
    
    # 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
    
    ########
    # SFTP #
    ########
    Subsystem sftp internal-sftp
    ####################
    # SFTP G:SFTP-ONLY #
    ####################
    Match Group sftp-only
    ChrootDirectory /sftp/%u/
    ForceCommand internal-sftp
    

    Restart sshd:

    /etc/init.d/sshd restart
    

    Przetestowałem to na CentOS 6.5

     

    Jak nie będzie działało to:

    1. Sprawdź czy masz włączonego SELinuxa

    2. Sprawdź czy logowanie na usera przebiega poprawnie (domyślnie w RHEL: /var/log/secure)

     

    Wielkie dzieki ! wszystko dziala !

     

    Ale znalazlem jeden problem. Struktora folderow wyglada tak :

     

    Home (root:root) ---> pliki (root:root) ---> access (user:user) ---> osoby (root:root) ---> pliki (user:user)

     

    I tak, chce aby niektórzy użytkownicy mieli dostep do access, a niektórzy tylko do pliki (ostatni folder) jak to zrobic ?

     

    Jak normalnie dodaje uzytkownikow i ustawiam ich na folder osoby to nie moge sie polaczyc z sftp jak zmienia praca folderu access na root:root wszystko dziala poprawnia...

     


  2. Docelowy dir musi być w posiadaniu roota.

     

    chown root:root /home/mojuser.

     

    Jest, ogolnie wszystko dziala (moge sie polaczyc przez sftp, ale dalej moge wyjsc z mojego home folderu) jak ustawienia sa na :

     

     

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

     

    Gdy zmieniam na :

     

     

    Subsystem sftp internal-sftp

     

    Match user testowy

    ChrootDirectory /home/testowy

    X11Forwarding no

    AllowTcpForwarding no

    ForceCommand internal-sftp

     

    FileZiilla wyrzuca :

     

     

    Connection refused

    Could not connect to server

    Co pojawiło się w logach po otrzymaniu komunikatu:

     

    ?

     

    Nic nie widzialem.


  3.  

    sshd_config:

    Match User test
        ChrootDirectory /home/test
        ForceCommand internal-sftp
    

    a właścicielem:

    # ls -ld /home/test/
    drwxr-xr-x 2 root root 4096 Sep  4 21:29 /home/test/
    
    

     

    Po tych ustawieniach nie mogę polaczyc sie z serwerem, wyrzuca :

     

     

    Error: Network error: Connection refused

    Error: Could not connect to server

     

    Co do samego pliku konfiguracyjnego :

    # 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
    #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 internal-sftp
    
    Match user testuser
    ChrootDirectory /home/testuser
    ForceCommand 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 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
    

    Reszte wszystko robione jak w linku z linode... Przerobilem tylke tutoriali i zaden nie dziala...


  4. Cześć,

     

    Spędziłem dzisiaj cały dzień walczac z ubuntu ale nie moge... nie moge tego zrobic, usiluje zamknac uzytkownika w jednym folderze, ale nie wazne co zrobie zawsze moge wyjsc z "home directory" i przegladac pliki serwerowe.

     

    Przerobilem dzisiaj tysiace tutoriali, przyklad :

    https://www.linode.com/docs/tools-reference/tools/limiting-access-with-sftp-jails-on-debian-and-ubuntu

     

    i caly czas to samo, logujac sie na sftp jestem w folderze uzytkownika, ale moge z niego wyjsc, jak zrobic aby zablokowac uzytkownika w tym folderze ?

     

    Pozdrawiam


  5. Cześć,

     

    Mam mały problem, zainstalowałem i skonfigurowalem ISPconfig na moim serwerze, wszystko dziala okej oprocz konta shell, potrzebuje stworzyc konto za posrednictwem ktorego polacze sie przez sftp z serwerem, ogolnie mam na nim jailkit'a ale cos nie dziala jak trzeba... ogolnie gdy sie loguje przez sftp do serwera to wrzuca mnie w dobra lokalizacje, ale moge wyjsc z mojego "home" folderu i przejsc do innych otwierac pliki. Jak moge zrobic aby konto shell mialo tylko i wylacznie dostep do danego folderu bez mozliwosci wchodzenia wyzej ??

     

    korzystam z pureftp


    konto zakladam przez ISPconfig w zakladce Shell konta

×