User Tools

Site Tools


sftp_centos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sftp_centos [2016/10/19 14:06] luke7858sftp_centos [2024/05/23 07:26] (current) – external edit 127.0.0.1
Line 59: Line 59:
 useradd -d /home/chroot/lukes-jail/ -s /sbin/nologin -G sftponly lukes-jail useradd -d /home/chroot/lukes-jail/ -s /sbin/nologin -G sftponly lukes-jail
 </sxh> </sxh>
-\\ 
 Now change the password with Now change the password with
 <sxh bash> <sxh bash>
Line 106: Line 105:
 \\ \\
 You should perform the following: You should perform the following:
 +== Option 1 ==
 <sxh bash> <sxh bash>
-chmod 711 /home/user/+chmod 711 /home/
  
 chmod 755 /home/lukes-jail/ chmod 755 /home/lukes-jail/
Line 117: Line 117:
 chown lukes-jail:sftponly /home/lukes-jail/website1/ chown lukes-jail:sftponly /home/lukes-jail/website1/
 </sxh> </sxh>
- +== Option 2 == 
 + <sxh bash> 
 +chmod 755 /home/chroot 
 + 
 +chown root:root /home/chroot/ 
 +</sxh>
 \\ \\
 === Mounting === === Mounting ===
  
 We can specify which directory we would like to mount and where. We need to edit /etc/fstab and type the following command. You will need to replace the first directory path with the path you wish to allow the sftp user access to. The second path is the chrooted sFTP users home directory. Add the following to the bottom of fstab: We can specify which directory we would like to mount and where. We need to edit /etc/fstab and type the following command. You will need to replace the first directory path with the path you wish to allow the sftp user access to. The second path is the chrooted sFTP users home directory. Add the following to the bottom of fstab:
 +== Option 1 ==
 +<sxh bash>
 +/var/www/vhost/lukeslinuxlessons/ /home/lukes-jail/website1/ none bind 0 0
 +</sxh>
 +
 +== Option 2 ==
 +\\
 <sxh bash> <sxh bash>
 /var/www/vhost/lukeslinuxlessons/ /home/chroot/lukes-jail/website1/ none bind 0 0 /var/www/vhost/lukeslinuxlessons/ /home/chroot/lukes-jail/website1/ none bind 0 0
Line 127: Line 139:
 Now we can mount a specific directory to the users chrooted home directory. Now we can mount a specific directory to the users chrooted home directory.
 \\ \\
-Best practice is to use the mount -a command to mount the directory using the entry we have just made. +Best practice is to use the "mountcommand (with a specific flag) to mount the directory using the entry we have just made. 
 \\ \\
 This is to make sure there are no errors in the entry into /etc/fstab. If there are errors, we can resolve them before the server is rebooted however if we dont fix them before server reboot it can cause **SEVERE** issue and prevent the server from booting!! This is to make sure there are no errors in the entry into /etc/fstab. If there are errors, we can resolve them before the server is rebooted however if we dont fix them before server reboot it can cause **SEVERE** issue and prevent the server from booting!!
Line 146: Line 158:
 Try logging in with the user via ssh, this should fail as we have disabled ssh login. Try logging in with the user via ssh, this should fail as we have disabled ssh login.
 <sxh bash> <sxh bash>
-ssh lukeisjailed@serverIP+ssh lukes-jail@serverIP
 </sxh> </sxh>
 Now we can test sftp via command line with Now we can test sftp via command line with
 <sxh bash> <sxh bash>
-sftp lukeisjailed@serverIP+sftp lukes-jail@serverIP
 </sxh> </sxh>
 This should prompt you for a password and then successfully log in. You should see: This should prompt you for a password and then successfully log in. You should see:
Line 177: Line 189:
 </sxh> </sxh>
 <sxh bash> <sxh bash>
-sftp -port user@host+sftp -P <portuser@host
 </sxh> </sxh>
  
sftp_centos.1476885975.txt.gz · Last modified: 2024/05/23 07:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki