Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 21/12/2015, à 08:34

Pepou06

[Résolu] MySecureShell - Permission denied

Bonjour,

Je viens d'installer MySecureShell afin de pouvoir restreindre les users dans leur /home/$USER

J'ai installé MySecureShell via le dépôt officiel (ubuntu 15.10) :

sudo apt-get install mysecureshell

J'ai modifié le fichier de configuration :

sudo nano /etc/ssh/sftp_config

Et voici son contenu :

#Default rules for everybody
<Default>
    Shell                   /bin/sh
#       GlobalDownload          800k    #total speed download for all clients
                                        # o -> bytes   k -> kilo bytes   m -> mega bytes
#       GlobalUpload            0       #total speed download for all clients (0 for unlimited)
        Download                0       #limit speed download for each connection
        Upload                  0       #unlimit speed upload for each connection
        StayAtHome              true    #limit client to his home
        VirtualChroot           true    #fake a chroot to the home account
        LimitConnection         10      #max connection for the server sftp
        LimitConnectionByUser   3       #max connection for the account
        LimitConnectionByIP     3       #max connection by ip for the account
        Home                    /home/$USER     #overrite home of the user but if you want you can use
                                                #       environment variable (ie: Home /home/$USER)
        IdleTimeOut             5m      #(in second) deconnect client is idle too long time
        ResolveIP               true    #resolve ip to dns
        DisableMakeDir          false
        DisableReadDir          false
        DisableRemoveDir        false
        DisableRemoveFile       false
        IgnoreHidden            true    #treat all hidden files as if they don't exist
#       DirFakeUser             true    #Hide real file/directory owner (just change displayed permissions)
#       DirFakeGroup            true    #Hide real file/directory group (just change displayed permissions)
#       DirFakeMode             0400    #Hide real file/directory rights (just change displayed permissions)
                                        #Add execution right for directory if read right is set
#       HideFiles               "^(lost\+found|public_html)$"   #Hide file/directory which match
                                                                #this extented POSIX regex
        HideNoAccess            false    #Hide file/directory which user has no access
#       MaxOpenFilesForUser     20      #limit user to open x files on same time
#       MaxWriteFilesForUser    10      #limit user to x upload on same time
#       MaxReadFilesForUser     10      #limit user to x download on same time
        DefaultRights           0644 0755       #Set default rights for new file and new directory
#       MinimumRights           0400 0700       #Set minimum rights for files and dirs

#       PathDenyFilter          "^\."   #deny upload of directory/file which match this extented POSIX regex

        ShowLinksAsLinks        false   #show links as their destinations
#       ConnectionMaxLife       1d      #limits connection lifetime to 1 day

#       Charset                 "ISO-8859-15"   #set charset of computer
#       GMTTime                 +1      #set GMT Time (change if necessary)
</Default>

Voici mon fichier de configuration ssh : /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
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 without-password
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

J'ai modifié le shell de l'utilisateur en question en remplaçant /bin/bash par /bin/MySecureShell :

sudo nano /etc/passwd

Quand j'essaie de me connecter au user en question j'obtiens dans mon terminal : Permission Denied.
Si j'essaie de me connecter via filezilla ou autre client j'obtiens Authentification Failed

Auriez-vous une piste afin de résoudre le problème ?

Merci d'avance !

Dernière modification par Pepou06 (Le 21/12/2015, à 11:22)

Hors ligne

#2 Le 21/12/2015, à 10:08

bruno

Re : [Résolu] MySecureShell - Permission denied

Bonjour,

J'ai modifié le shell de l'utilisateur en question en remplaçant /bin/bash par /bin/MySecureShell

C'est plutôt /usr/bin/mysecureshell et c'est un peu bourrin de modifier directement /etc/password (usermod est ton ami…)

Je n'ai pas vraiment examiné le reste mais est-tu sûr d'avoir vraiment besoin de mysecureshell ? Si tu veux juste donner un accès SFTP, sans interpréteur de commandes, à tes utilisateurs ; c'est inutile.

Dernière modification par bruno (Le 21/12/2015, à 10:09)

Hors ligne

#3 Le 21/12/2015, à 11:12

Pepou06

Re : [Résolu] MySecureShell - Permission denied

Merci pour ta réponse !
Comment restreindre les users dans leur home sans passer par mysecureshell ?

Hors ligne

#4 Le 21/12/2015, à 11:18

bruno

Re : [Résolu] MySecureShell - Permission denied

Regarde la doc de ssh-server il y a une directive ChrootDirectory. Cela a déjà du être discuté dans le forum.

https://www.debian-administration.org/a … tDirectory
https://wiki.archlinux.org/index.php/SFTP_chroot
https://kdecherf.com/blog/2009/03/01/cr … c-openssh/

Hors ligne

#5 Le 21/12/2015, à 11:21

Pepou06

Re : [Résolu] MySecureShell - Permission denied

Bon si non MERCI !! tu viens de résoudre mon problème..

La commande :

whereis mysecureshell

mysecureshell: /usr/bin/mysecureshell /usr/share/man/man8/mysecureshell.8.gz

Et donc en remplaçant : /bin/mysecureshell par /usr/bin/mysecureshell ==> problème résolu ! smile
Merci !

Hors ligne