LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   is it possible to SFTP and FTP to same directory ? (https://www.linuxquestions.org/questions/linux-newbie-8/is-it-possible-to-sftp-and-ftp-to-same-directory-4175517620/)

ratotopi 09-06-2014 02:57 PM

is it possible to SFTP and FTP to same directory ?
 
Here are the step I did and I am having problem resolving this issue,
I created chrooted directory for sftp and the ChrootedDrectory looks like this
Match Group sftp
ForceCommand internal-sftp
AllowTcpForwarding no
ChrootDirectory /chroot/home/%u


I added sftp user with
useradd -g sftp -d /sftp user

The /chroot/home directory is own by root:root and chmod is 755, as required by chrooted sftp.When I sftp to the server as the user everything works fine and I am able to do the sftp without any problem as it takes me directly to the /sftp directory of the user.
My problem arises when I need to make same user ftp to the same directory /chroot/home/user/sftp
but when i do ftp to the server with that username it come back with no /sftp directory
so I change the home directory of user to
usermod -d /chroot/home/user/sftp user

I am able to ftp to the directory /sftp directly and ftp is ok
but now another problem comes when I do the sftp as the same user it will not take me to /sftp directory of the user but his /chroot/home/user directory which is own by root and sftp does not allow to do anything inside that directory you will have to cd to /sftp of the user directory before you do anything. My question is, can the user directly sftp or ftp to /chroot/home/user/sftp directory without having this issue, the user should not have to login as sftp user@server:/sftp or cd to /sftp directory after login from sftp. I tried to change user bashrc and profile file to cd to /sftp once they login but it does not work. I will be very thankful for any idea you can provide. How can I achieve user with sftp and ftp to able to work on same directory once they login. Thank you very much.

wpeckham 09-06-2014 03:30 PM

ftp and sftp - WITH CHROOT
 
What you want to do IS possible, but you need to use tools that understand chroot the same way, and set them up to work with the same rule.

I assume, form the detail you provided, that you are using OpenSSH for your sftp server.
What is your ftp server? Have you read the documentation re: CHROOT for that package?

I would set it up so SFTP works perfectly, then leave that side alone and change your FTP server. VSFTP is one that should support your configuration, and should be in most REPOS lists.

ratotopi 09-06-2014 03:42 PM

Thank you wpeckham for your input so are you suggesting to do the chroot for the vsftp and make it same like sftp chroot ? I am using OpenSSH and vsftp . I did setup sftp first but when i setup the vsftp it didnt work as vsftp didnt see user /sftp directory so i had to make changes


All times are GMT -5. The time now is 05:41 AM.