Če želimo omogočiti SFTP dostop in preprečiti SSH dostop, ter onemogočiti uporabniku dostop do drugih direktorijev, lahko to naredimo z naslednjimi koraki:
1.) Kreiramo direktorij, do katerega bo uporabnik imel dostop
1 2 3 4 | cd /home
mkdir sftpdir
cd sftpdir
mkdir sftp1 |
2.) Kreiramo novo grupo in uporabnika
5 | groupadd sftpgroup |
*uporabnika dodamo skupini z “-G” in mu nastavimo home direktorij “-d” , en nivo nižje od njegovega (sftp1)
6 | useradd -G sftpgroup -d /home/sftpmapa sftpuser |
*uporabniku določimo geslo
7 | passwd sftpuser |
3.) Popravimo lastništvo sftp1 direktorija tako, da bo owner root in group sftpgroup.
8 | chown root:sftpgroup /home/sftpdir/sftp1 |
4.) Odpremo konfiguracijsko datoteko “/etc/ssh/sshd_config” in dodamo naslednje parametre.
………………………………………………………………………..
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
Match Group sftpgroup
ChrootDirectory /home/sftpmapa
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
# 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
…………………………………………………………………………………………….
5.) Omogočimo uporabniku dostop le do SFTP-ja in nič drugega.
9 | usermod -s "/usr/libexec/openssh/sftp-server" sftpuser |
6.) Za zakjuček resetiramo ssh servis z ukazom:
10 | service ssh restart |
*Tako, sedaj lahko uporabnik dostopa le do svojega direktorija in ne more nižje.
Leave a Reply