Can I make a user's home directory be /var/www/html for vsftp?











up vote
1
down vote

favorite












I have an Ubuntu 16.04 web server. It only hosts one site using Nginx. I want to keep things very simple, and store the index.html file and the whole website in /var/www/html.



I need to be able to FTP files into /var/www/html. I have installed vsftp. I've created a user with the useradd command, which I'll call exampleuser. I then used this command:



sudo usermod -d /var/www/html exampleuser


... thinking that this would make the home directory of exampleuser to be the default directory when I log in by FTP.



However, when I attempt to log in by FTP, I get a "login error". I've checked and double checked my username and password and I'm certain they're correct, so I'm guessing it's a permissions issue (also because my experience is that most of the time in Linux when things don't work as hoped it's because of permissions). Though it's possible it could be a vsftpd configurations issue.



I think I've set the html directory in /var/www to have the right access:



/var/www$ ls -la
total 12
drwxr-xr-x 3 root root 4096 Nov 10 06:54 .
drwxr-xr-x 14 root root 4096 Nov 10 06:54 ..
drwxr-xr-x 2 exampleuser exampleuser 4096 Nov 10 08:04 html


What do I need to do so that I can ftp to /var/www/html?










share|improve this question






















  • Not a security expert but why not have sudo rm /var/www and then have sampleuser create /var/www and /var/www/html? Also does the directory have to be in /var which is a system folder?
    – WinEunuuchs2Unix
    Nov 11 '16 at 17:07










  • What is the log in error ?
    – Panther
    Nov 11 '16 at 17:10










  • @bodhi.zazen, my client says "Login failed." The vsftp log says "FAIL LOGIN: Client".
    – Questioner
    Nov 11 '16 at 17:18










  • What error is in your logs ? Simply stating it is not working and guessing at the problem is not going to make much progress. See also help.ubuntu.com/community/… as your directories do not have proper permissions.
    – Panther
    Nov 11 '16 at 17:18






  • 1




    I am not sure it is a permissions problem. You can try making /var and /var/www rwx by your other user, although that has it's own security problems.
    – Panther
    Nov 11 '16 at 17:36















up vote
1
down vote

favorite












I have an Ubuntu 16.04 web server. It only hosts one site using Nginx. I want to keep things very simple, and store the index.html file and the whole website in /var/www/html.



I need to be able to FTP files into /var/www/html. I have installed vsftp. I've created a user with the useradd command, which I'll call exampleuser. I then used this command:



sudo usermod -d /var/www/html exampleuser


... thinking that this would make the home directory of exampleuser to be the default directory when I log in by FTP.



However, when I attempt to log in by FTP, I get a "login error". I've checked and double checked my username and password and I'm certain they're correct, so I'm guessing it's a permissions issue (also because my experience is that most of the time in Linux when things don't work as hoped it's because of permissions). Though it's possible it could be a vsftpd configurations issue.



I think I've set the html directory in /var/www to have the right access:



/var/www$ ls -la
total 12
drwxr-xr-x 3 root root 4096 Nov 10 06:54 .
drwxr-xr-x 14 root root 4096 Nov 10 06:54 ..
drwxr-xr-x 2 exampleuser exampleuser 4096 Nov 10 08:04 html


What do I need to do so that I can ftp to /var/www/html?










share|improve this question






















  • Not a security expert but why not have sudo rm /var/www and then have sampleuser create /var/www and /var/www/html? Also does the directory have to be in /var which is a system folder?
    – WinEunuuchs2Unix
    Nov 11 '16 at 17:07










  • What is the log in error ?
    – Panther
    Nov 11 '16 at 17:10










  • @bodhi.zazen, my client says "Login failed." The vsftp log says "FAIL LOGIN: Client".
    – Questioner
    Nov 11 '16 at 17:18










  • What error is in your logs ? Simply stating it is not working and guessing at the problem is not going to make much progress. See also help.ubuntu.com/community/… as your directories do not have proper permissions.
    – Panther
    Nov 11 '16 at 17:18






  • 1




    I am not sure it is a permissions problem. You can try making /var and /var/www rwx by your other user, although that has it's own security problems.
    – Panther
    Nov 11 '16 at 17:36













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have an Ubuntu 16.04 web server. It only hosts one site using Nginx. I want to keep things very simple, and store the index.html file and the whole website in /var/www/html.



I need to be able to FTP files into /var/www/html. I have installed vsftp. I've created a user with the useradd command, which I'll call exampleuser. I then used this command:



sudo usermod -d /var/www/html exampleuser


... thinking that this would make the home directory of exampleuser to be the default directory when I log in by FTP.



However, when I attempt to log in by FTP, I get a "login error". I've checked and double checked my username and password and I'm certain they're correct, so I'm guessing it's a permissions issue (also because my experience is that most of the time in Linux when things don't work as hoped it's because of permissions). Though it's possible it could be a vsftpd configurations issue.



I think I've set the html directory in /var/www to have the right access:



/var/www$ ls -la
total 12
drwxr-xr-x 3 root root 4096 Nov 10 06:54 .
drwxr-xr-x 14 root root 4096 Nov 10 06:54 ..
drwxr-xr-x 2 exampleuser exampleuser 4096 Nov 10 08:04 html


What do I need to do so that I can ftp to /var/www/html?










share|improve this question













I have an Ubuntu 16.04 web server. It only hosts one site using Nginx. I want to keep things very simple, and store the index.html file and the whole website in /var/www/html.



I need to be able to FTP files into /var/www/html. I have installed vsftp. I've created a user with the useradd command, which I'll call exampleuser. I then used this command:



sudo usermod -d /var/www/html exampleuser


... thinking that this would make the home directory of exampleuser to be the default directory when I log in by FTP.



However, when I attempt to log in by FTP, I get a "login error". I've checked and double checked my username and password and I'm certain they're correct, so I'm guessing it's a permissions issue (also because my experience is that most of the time in Linux when things don't work as hoped it's because of permissions). Though it's possible it could be a vsftpd configurations issue.



I think I've set the html directory in /var/www to have the right access:



/var/www$ ls -la
total 12
drwxr-xr-x 3 root root 4096 Nov 10 06:54 .
drwxr-xr-x 14 root root 4096 Nov 10 06:54 ..
drwxr-xr-x 2 exampleuser exampleuser 4096 Nov 10 08:04 html


What do I need to do so that I can ftp to /var/www/html?







server permissions ftp vsftpd






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 '16 at 16:54









Questioner

1,4882482147




1,4882482147












  • Not a security expert but why not have sudo rm /var/www and then have sampleuser create /var/www and /var/www/html? Also does the directory have to be in /var which is a system folder?
    – WinEunuuchs2Unix
    Nov 11 '16 at 17:07










  • What is the log in error ?
    – Panther
    Nov 11 '16 at 17:10










  • @bodhi.zazen, my client says "Login failed." The vsftp log says "FAIL LOGIN: Client".
    – Questioner
    Nov 11 '16 at 17:18










  • What error is in your logs ? Simply stating it is not working and guessing at the problem is not going to make much progress. See also help.ubuntu.com/community/… as your directories do not have proper permissions.
    – Panther
    Nov 11 '16 at 17:18






  • 1




    I am not sure it is a permissions problem. You can try making /var and /var/www rwx by your other user, although that has it's own security problems.
    – Panther
    Nov 11 '16 at 17:36


















  • Not a security expert but why not have sudo rm /var/www and then have sampleuser create /var/www and /var/www/html? Also does the directory have to be in /var which is a system folder?
    – WinEunuuchs2Unix
    Nov 11 '16 at 17:07










  • What is the log in error ?
    – Panther
    Nov 11 '16 at 17:10










  • @bodhi.zazen, my client says "Login failed." The vsftp log says "FAIL LOGIN: Client".
    – Questioner
    Nov 11 '16 at 17:18










  • What error is in your logs ? Simply stating it is not working and guessing at the problem is not going to make much progress. See also help.ubuntu.com/community/… as your directories do not have proper permissions.
    – Panther
    Nov 11 '16 at 17:18






  • 1




    I am not sure it is a permissions problem. You can try making /var and /var/www rwx by your other user, although that has it's own security problems.
    – Panther
    Nov 11 '16 at 17:36
















Not a security expert but why not have sudo rm /var/www and then have sampleuser create /var/www and /var/www/html? Also does the directory have to be in /var which is a system folder?
– WinEunuuchs2Unix
Nov 11 '16 at 17:07




Not a security expert but why not have sudo rm /var/www and then have sampleuser create /var/www and /var/www/html? Also does the directory have to be in /var which is a system folder?
– WinEunuuchs2Unix
Nov 11 '16 at 17:07












What is the log in error ?
– Panther
Nov 11 '16 at 17:10




What is the log in error ?
– Panther
Nov 11 '16 at 17:10












@bodhi.zazen, my client says "Login failed." The vsftp log says "FAIL LOGIN: Client".
– Questioner
Nov 11 '16 at 17:18




@bodhi.zazen, my client says "Login failed." The vsftp log says "FAIL LOGIN: Client".
– Questioner
Nov 11 '16 at 17:18












What error is in your logs ? Simply stating it is not working and guessing at the problem is not going to make much progress. See also help.ubuntu.com/community/… as your directories do not have proper permissions.
– Panther
Nov 11 '16 at 17:18




What error is in your logs ? Simply stating it is not working and guessing at the problem is not going to make much progress. See also help.ubuntu.com/community/… as your directories do not have proper permissions.
– Panther
Nov 11 '16 at 17:18




1




1




I am not sure it is a permissions problem. You can try making /var and /var/www rwx by your other user, although that has it's own security problems.
– Panther
Nov 11 '16 at 17:36




I am not sure it is a permissions problem. You can try making /var and /var/www rwx by your other user, although that has it's own security problems.
– Panther
Nov 11 '16 at 17:36










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Yes it is a permission error take a look on this tutorial:




FTP is generally more secure when users are restricted to a specific
directory.vsftpd accomplishes this with chroot jails. When chroot is
enabled for local users, they are restricted to their home directory
by default. However, because of the way vsftpd secures the directory,
it must not be writable by the user. This is fine for a new user who
should only connect via FTP, but an existing user may need to write to
their home folder if they also shell access.



In this example, rather than removing write privileges from the home
directory, we're will create an ftp directory to serve as the chroot
and a writable files directory to hold the actual files.



Create the ftp folder, set its ownership, and be sure to remove write
permissions with the following commands:




sudo mkdir /home/sammy/ftp
sudo chown nobody:nogroup /home/sammy/ftp
sudo chmod a-w /home/sammy/ftp


If you try to connect to the ftp and the user can write the folder then it wont connect, you need to add to the root folder the owner nobody:nogroup, so if you want to keep things simple just point your server to the folder where the user can write in your case:



sudo usermod -d /var/www exampleuser


This is because you want to write on HTML folder



sudo chown nobody:nogroup /var/www
sudo chmod a-w /var/www


Modify your server conf file and point to the new location which will be HTML this solution helps a lot if you really want to use Very Safe FTP






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f848274%2fcan-i-make-a-users-home-directory-be-var-www-html-for-vsftp%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Yes it is a permission error take a look on this tutorial:




    FTP is generally more secure when users are restricted to a specific
    directory.vsftpd accomplishes this with chroot jails. When chroot is
    enabled for local users, they are restricted to their home directory
    by default. However, because of the way vsftpd secures the directory,
    it must not be writable by the user. This is fine for a new user who
    should only connect via FTP, but an existing user may need to write to
    their home folder if they also shell access.



    In this example, rather than removing write privileges from the home
    directory, we're will create an ftp directory to serve as the chroot
    and a writable files directory to hold the actual files.



    Create the ftp folder, set its ownership, and be sure to remove write
    permissions with the following commands:




    sudo mkdir /home/sammy/ftp
    sudo chown nobody:nogroup /home/sammy/ftp
    sudo chmod a-w /home/sammy/ftp


    If you try to connect to the ftp and the user can write the folder then it wont connect, you need to add to the root folder the owner nobody:nogroup, so if you want to keep things simple just point your server to the folder where the user can write in your case:



    sudo usermod -d /var/www exampleuser


    This is because you want to write on HTML folder



    sudo chown nobody:nogroup /var/www
    sudo chmod a-w /var/www


    Modify your server conf file and point to the new location which will be HTML this solution helps a lot if you really want to use Very Safe FTP






    share|improve this answer

























      up vote
      0
      down vote













      Yes it is a permission error take a look on this tutorial:




      FTP is generally more secure when users are restricted to a specific
      directory.vsftpd accomplishes this with chroot jails. When chroot is
      enabled for local users, they are restricted to their home directory
      by default. However, because of the way vsftpd secures the directory,
      it must not be writable by the user. This is fine for a new user who
      should only connect via FTP, but an existing user may need to write to
      their home folder if they also shell access.



      In this example, rather than removing write privileges from the home
      directory, we're will create an ftp directory to serve as the chroot
      and a writable files directory to hold the actual files.



      Create the ftp folder, set its ownership, and be sure to remove write
      permissions with the following commands:




      sudo mkdir /home/sammy/ftp
      sudo chown nobody:nogroup /home/sammy/ftp
      sudo chmod a-w /home/sammy/ftp


      If you try to connect to the ftp and the user can write the folder then it wont connect, you need to add to the root folder the owner nobody:nogroup, so if you want to keep things simple just point your server to the folder where the user can write in your case:



      sudo usermod -d /var/www exampleuser


      This is because you want to write on HTML folder



      sudo chown nobody:nogroup /var/www
      sudo chmod a-w /var/www


      Modify your server conf file and point to the new location which will be HTML this solution helps a lot if you really want to use Very Safe FTP






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Yes it is a permission error take a look on this tutorial:




        FTP is generally more secure when users are restricted to a specific
        directory.vsftpd accomplishes this with chroot jails. When chroot is
        enabled for local users, they are restricted to their home directory
        by default. However, because of the way vsftpd secures the directory,
        it must not be writable by the user. This is fine for a new user who
        should only connect via FTP, but an existing user may need to write to
        their home folder if they also shell access.



        In this example, rather than removing write privileges from the home
        directory, we're will create an ftp directory to serve as the chroot
        and a writable files directory to hold the actual files.



        Create the ftp folder, set its ownership, and be sure to remove write
        permissions with the following commands:




        sudo mkdir /home/sammy/ftp
        sudo chown nobody:nogroup /home/sammy/ftp
        sudo chmod a-w /home/sammy/ftp


        If you try to connect to the ftp and the user can write the folder then it wont connect, you need to add to the root folder the owner nobody:nogroup, so if you want to keep things simple just point your server to the folder where the user can write in your case:



        sudo usermod -d /var/www exampleuser


        This is because you want to write on HTML folder



        sudo chown nobody:nogroup /var/www
        sudo chmod a-w /var/www


        Modify your server conf file and point to the new location which will be HTML this solution helps a lot if you really want to use Very Safe FTP






        share|improve this answer












        Yes it is a permission error take a look on this tutorial:




        FTP is generally more secure when users are restricted to a specific
        directory.vsftpd accomplishes this with chroot jails. When chroot is
        enabled for local users, they are restricted to their home directory
        by default. However, because of the way vsftpd secures the directory,
        it must not be writable by the user. This is fine for a new user who
        should only connect via FTP, but an existing user may need to write to
        their home folder if they also shell access.



        In this example, rather than removing write privileges from the home
        directory, we're will create an ftp directory to serve as the chroot
        and a writable files directory to hold the actual files.



        Create the ftp folder, set its ownership, and be sure to remove write
        permissions with the following commands:




        sudo mkdir /home/sammy/ftp
        sudo chown nobody:nogroup /home/sammy/ftp
        sudo chmod a-w /home/sammy/ftp


        If you try to connect to the ftp and the user can write the folder then it wont connect, you need to add to the root folder the owner nobody:nogroup, so if you want to keep things simple just point your server to the folder where the user can write in your case:



        sudo usermod -d /var/www exampleuser


        This is because you want to write on HTML folder



        sudo chown nobody:nogroup /var/www
        sudo chmod a-w /var/www


        Modify your server conf file and point to the new location which will be HTML this solution helps a lot if you really want to use Very Safe FTP







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 1 '17 at 20:38









        Rodolfo Abarca

        1012




        1012






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f848274%2fcan-i-make-a-users-home-directory-be-var-www-html-for-vsftp%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            數位音樂下載

            When can things happen in Etherscan, such as the picture below?

            格利澤436b