Configuring FTP server in redhat

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I have installed vsftpd in redhat. Everything was file untill I fould that when I log into ftp server using:




ftp localhost




or fileZilla I get following errors:



ERROR:
- 500 OOPS: cannot change directory:/foo



Also, when I change the log directory from



- /var/log/xferlog


to



- /usr/local/data


Then I get:



 500 OOPS: failed to open xferlog log file:/usr/local/data/vsftpd.log


From this link the SOLUTION seems to be:



This happens because SELinux isn’t properly configured for your ftp service. Either disable SELinux or configure it for ftp.

To disable SELinux, edit /etc/selinux/config and set “SELINUX=disabled”, then reboot.


How do I enable ftp without disableing SElinux?










share|improve this question


























    1















    I have installed vsftpd in redhat. Everything was file untill I fould that when I log into ftp server using:




    ftp localhost




    or fileZilla I get following errors:



    ERROR:
    - 500 OOPS: cannot change directory:/foo



    Also, when I change the log directory from



    - /var/log/xferlog


    to



    - /usr/local/data


    Then I get:



     500 OOPS: failed to open xferlog log file:/usr/local/data/vsftpd.log


    From this link the SOLUTION seems to be:



    This happens because SELinux isn’t properly configured for your ftp service. Either disable SELinux or configure it for ftp.

    To disable SELinux, edit /etc/selinux/config and set “SELINUX=disabled”, then reboot.


    How do I enable ftp without disableing SElinux?










    share|improve this question
























      1












      1








      1








      I have installed vsftpd in redhat. Everything was file untill I fould that when I log into ftp server using:




      ftp localhost




      or fileZilla I get following errors:



      ERROR:
      - 500 OOPS: cannot change directory:/foo



      Also, when I change the log directory from



      - /var/log/xferlog


      to



      - /usr/local/data


      Then I get:



       500 OOPS: failed to open xferlog log file:/usr/local/data/vsftpd.log


      From this link the SOLUTION seems to be:



      This happens because SELinux isn’t properly configured for your ftp service. Either disable SELinux or configure it for ftp.

      To disable SELinux, edit /etc/selinux/config and set “SELINUX=disabled”, then reboot.


      How do I enable ftp without disableing SElinux?










      share|improve this question














      I have installed vsftpd in redhat. Everything was file untill I fould that when I log into ftp server using:




      ftp localhost




      or fileZilla I get following errors:



      ERROR:
      - 500 OOPS: cannot change directory:/foo



      Also, when I change the log directory from



      - /var/log/xferlog


      to



      - /usr/local/data


      Then I get:



       500 OOPS: failed to open xferlog log file:/usr/local/data/vsftpd.log


      From this link the SOLUTION seems to be:



      This happens because SELinux isn’t properly configured for your ftp service. Either disable SELinux or configure it for ftp.

      To disable SELinux, edit /etc/selinux/config and set “SELINUX=disabled”, then reboot.


      How do I enable ftp without disableing SElinux?







      rhel ftp selinux vsftpd






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 1 '14 at 10:50









      kinkajoukinkajou

      2851411




      2851411




















          3 Answers
          3






          active

          oldest

          votes


















          1














          SELinux won't let vsftpd serve files from places other than /var/ftp or write logs outside /var/log on purpose. SELinux is all about disaster mitigation. FTP is fundamentally insecure. Running vsftpd under SELinux is a good idea, because it minimizes the damage an attacker can do if he decides to attack your FTP service.



          Running a fundamentally insecure service like vsftpd without locking it down with SELinux is foolish.



          If you absolutely must reconfigure it like this, you need to rewrite the FTP related SELinux policies, but that's not a trivial job. The audit2allow tool can help.



          If you decide that disabling SELinux is too risky and building a new SELinux policy is too difficult, I'd recommend using SFTP or scp instead. RHEL ships with sshd configured and running, so you don't have to do anything special to get this working.






          share|improve this answer






























            1














            You can usually find selinux denials in /var/log/messages. Try this (as root):



            grep avc /var/log/messages | grep ftp


            Review the output and decide whether the denials are erroneous, given your desired configuration. Tune the grep statements as necessary to whiddle the information down to only the statements you want to fix. It's often useful to temporarily put the system in permissive mode (setenforce 0), then perform the operations you expect to need. /var/log/messages will amass a list of errors that need to be fixed in your SELinux policy. Once you're satisfied with the list of denials that need to be fixed, generate a new policy using the following:



            # ensure you have audit2allow
            which audit2allow

            # if no audit2allow, install it:
            yum install policycoreutils-python

            # replace the following with your tuned grep (if necessary)
            grep avc /var/log/message | grep ftp | audit2allow -M my_vsftp


            In your current directory, there will be two new files: my_vsftp.te and my_vsftp.pp. the *.te file is readable, the *.pp is compiled. Review the *.te file to ensure it is appropriate.



            Be careful here, as opening up too many SELinux rules can leave you vulnerable. It is highly recommended to read up on SELinux.



            cat my_vsftp.te


            If the policy looks appropriate, install and activate it:



            mkdir /usr/share/selinux/packages/my_vsftp
            mv my_vsftp.* /usr/share/selinux/packages/my_vsftp/
            semodule -i /usr/share/selinux/packages/my_vsftp/my_vsftp.pp


            Ensure the system is enforcing (getenforce, setenforce 1), and test your FTP server, monitoring /var/log/messages for denials.






            share|improve this answer






























              0














              A slightly heavy-handed solution to allow vsftpd access anywhere, would be:



              setsebool -P allow_ftpd_full_access=1


              At that point, vsftpd can go pretty much anywhere on the system...






              share|improve this answer






















                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "106"
                ;
                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',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                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%2funix.stackexchange.com%2fquestions%2f122552%2fconfiguring-ftp-server-in-redhat%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1














                SELinux won't let vsftpd serve files from places other than /var/ftp or write logs outside /var/log on purpose. SELinux is all about disaster mitigation. FTP is fundamentally insecure. Running vsftpd under SELinux is a good idea, because it minimizes the damage an attacker can do if he decides to attack your FTP service.



                Running a fundamentally insecure service like vsftpd without locking it down with SELinux is foolish.



                If you absolutely must reconfigure it like this, you need to rewrite the FTP related SELinux policies, but that's not a trivial job. The audit2allow tool can help.



                If you decide that disabling SELinux is too risky and building a new SELinux policy is too difficult, I'd recommend using SFTP or scp instead. RHEL ships with sshd configured and running, so you don't have to do anything special to get this working.






                share|improve this answer



























                  1














                  SELinux won't let vsftpd serve files from places other than /var/ftp or write logs outside /var/log on purpose. SELinux is all about disaster mitigation. FTP is fundamentally insecure. Running vsftpd under SELinux is a good idea, because it minimizes the damage an attacker can do if he decides to attack your FTP service.



                  Running a fundamentally insecure service like vsftpd without locking it down with SELinux is foolish.



                  If you absolutely must reconfigure it like this, you need to rewrite the FTP related SELinux policies, but that's not a trivial job. The audit2allow tool can help.



                  If you decide that disabling SELinux is too risky and building a new SELinux policy is too difficult, I'd recommend using SFTP or scp instead. RHEL ships with sshd configured and running, so you don't have to do anything special to get this working.






                  share|improve this answer

























                    1












                    1








                    1







                    SELinux won't let vsftpd serve files from places other than /var/ftp or write logs outside /var/log on purpose. SELinux is all about disaster mitigation. FTP is fundamentally insecure. Running vsftpd under SELinux is a good idea, because it minimizes the damage an attacker can do if he decides to attack your FTP service.



                    Running a fundamentally insecure service like vsftpd without locking it down with SELinux is foolish.



                    If you absolutely must reconfigure it like this, you need to rewrite the FTP related SELinux policies, but that's not a trivial job. The audit2allow tool can help.



                    If you decide that disabling SELinux is too risky and building a new SELinux policy is too difficult, I'd recommend using SFTP or scp instead. RHEL ships with sshd configured and running, so you don't have to do anything special to get this working.






                    share|improve this answer













                    SELinux won't let vsftpd serve files from places other than /var/ftp or write logs outside /var/log on purpose. SELinux is all about disaster mitigation. FTP is fundamentally insecure. Running vsftpd under SELinux is a good idea, because it minimizes the damage an attacker can do if he decides to attack your FTP service.



                    Running a fundamentally insecure service like vsftpd without locking it down with SELinux is foolish.



                    If you absolutely must reconfigure it like this, you need to rewrite the FTP related SELinux policies, but that's not a trivial job. The audit2allow tool can help.



                    If you decide that disabling SELinux is too risky and building a new SELinux policy is too difficult, I'd recommend using SFTP or scp instead. RHEL ships with sshd configured and running, so you don't have to do anything special to get this working.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 1 '14 at 12:02









                    Warren YoungWarren Young

                    55.4k11143148




                    55.4k11143148























                        1














                        You can usually find selinux denials in /var/log/messages. Try this (as root):



                        grep avc /var/log/messages | grep ftp


                        Review the output and decide whether the denials are erroneous, given your desired configuration. Tune the grep statements as necessary to whiddle the information down to only the statements you want to fix. It's often useful to temporarily put the system in permissive mode (setenforce 0), then perform the operations you expect to need. /var/log/messages will amass a list of errors that need to be fixed in your SELinux policy. Once you're satisfied with the list of denials that need to be fixed, generate a new policy using the following:



                        # ensure you have audit2allow
                        which audit2allow

                        # if no audit2allow, install it:
                        yum install policycoreutils-python

                        # replace the following with your tuned grep (if necessary)
                        grep avc /var/log/message | grep ftp | audit2allow -M my_vsftp


                        In your current directory, there will be two new files: my_vsftp.te and my_vsftp.pp. the *.te file is readable, the *.pp is compiled. Review the *.te file to ensure it is appropriate.



                        Be careful here, as opening up too many SELinux rules can leave you vulnerable. It is highly recommended to read up on SELinux.



                        cat my_vsftp.te


                        If the policy looks appropriate, install and activate it:



                        mkdir /usr/share/selinux/packages/my_vsftp
                        mv my_vsftp.* /usr/share/selinux/packages/my_vsftp/
                        semodule -i /usr/share/selinux/packages/my_vsftp/my_vsftp.pp


                        Ensure the system is enforcing (getenforce, setenforce 1), and test your FTP server, monitoring /var/log/messages for denials.






                        share|improve this answer



























                          1














                          You can usually find selinux denials in /var/log/messages. Try this (as root):



                          grep avc /var/log/messages | grep ftp


                          Review the output and decide whether the denials are erroneous, given your desired configuration. Tune the grep statements as necessary to whiddle the information down to only the statements you want to fix. It's often useful to temporarily put the system in permissive mode (setenforce 0), then perform the operations you expect to need. /var/log/messages will amass a list of errors that need to be fixed in your SELinux policy. Once you're satisfied with the list of denials that need to be fixed, generate a new policy using the following:



                          # ensure you have audit2allow
                          which audit2allow

                          # if no audit2allow, install it:
                          yum install policycoreutils-python

                          # replace the following with your tuned grep (if necessary)
                          grep avc /var/log/message | grep ftp | audit2allow -M my_vsftp


                          In your current directory, there will be two new files: my_vsftp.te and my_vsftp.pp. the *.te file is readable, the *.pp is compiled. Review the *.te file to ensure it is appropriate.



                          Be careful here, as opening up too many SELinux rules can leave you vulnerable. It is highly recommended to read up on SELinux.



                          cat my_vsftp.te


                          If the policy looks appropriate, install and activate it:



                          mkdir /usr/share/selinux/packages/my_vsftp
                          mv my_vsftp.* /usr/share/selinux/packages/my_vsftp/
                          semodule -i /usr/share/selinux/packages/my_vsftp/my_vsftp.pp


                          Ensure the system is enforcing (getenforce, setenforce 1), and test your FTP server, monitoring /var/log/messages for denials.






                          share|improve this answer

























                            1












                            1








                            1







                            You can usually find selinux denials in /var/log/messages. Try this (as root):



                            grep avc /var/log/messages | grep ftp


                            Review the output and decide whether the denials are erroneous, given your desired configuration. Tune the grep statements as necessary to whiddle the information down to only the statements you want to fix. It's often useful to temporarily put the system in permissive mode (setenforce 0), then perform the operations you expect to need. /var/log/messages will amass a list of errors that need to be fixed in your SELinux policy. Once you're satisfied with the list of denials that need to be fixed, generate a new policy using the following:



                            # ensure you have audit2allow
                            which audit2allow

                            # if no audit2allow, install it:
                            yum install policycoreutils-python

                            # replace the following with your tuned grep (if necessary)
                            grep avc /var/log/message | grep ftp | audit2allow -M my_vsftp


                            In your current directory, there will be two new files: my_vsftp.te and my_vsftp.pp. the *.te file is readable, the *.pp is compiled. Review the *.te file to ensure it is appropriate.



                            Be careful here, as opening up too many SELinux rules can leave you vulnerable. It is highly recommended to read up on SELinux.



                            cat my_vsftp.te


                            If the policy looks appropriate, install and activate it:



                            mkdir /usr/share/selinux/packages/my_vsftp
                            mv my_vsftp.* /usr/share/selinux/packages/my_vsftp/
                            semodule -i /usr/share/selinux/packages/my_vsftp/my_vsftp.pp


                            Ensure the system is enforcing (getenforce, setenforce 1), and test your FTP server, monitoring /var/log/messages for denials.






                            share|improve this answer













                            You can usually find selinux denials in /var/log/messages. Try this (as root):



                            grep avc /var/log/messages | grep ftp


                            Review the output and decide whether the denials are erroneous, given your desired configuration. Tune the grep statements as necessary to whiddle the information down to only the statements you want to fix. It's often useful to temporarily put the system in permissive mode (setenforce 0), then perform the operations you expect to need. /var/log/messages will amass a list of errors that need to be fixed in your SELinux policy. Once you're satisfied with the list of denials that need to be fixed, generate a new policy using the following:



                            # ensure you have audit2allow
                            which audit2allow

                            # if no audit2allow, install it:
                            yum install policycoreutils-python

                            # replace the following with your tuned grep (if necessary)
                            grep avc /var/log/message | grep ftp | audit2allow -M my_vsftp


                            In your current directory, there will be two new files: my_vsftp.te and my_vsftp.pp. the *.te file is readable, the *.pp is compiled. Review the *.te file to ensure it is appropriate.



                            Be careful here, as opening up too many SELinux rules can leave you vulnerable. It is highly recommended to read up on SELinux.



                            cat my_vsftp.te


                            If the policy looks appropriate, install and activate it:



                            mkdir /usr/share/selinux/packages/my_vsftp
                            mv my_vsftp.* /usr/share/selinux/packages/my_vsftp/
                            semodule -i /usr/share/selinux/packages/my_vsftp/my_vsftp.pp


                            Ensure the system is enforcing (getenforce, setenforce 1), and test your FTP server, monitoring /var/log/messages for denials.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 1 '14 at 14:40









                            Nick SabineNick Sabine

                            1243




                            1243





















                                0














                                A slightly heavy-handed solution to allow vsftpd access anywhere, would be:



                                setsebool -P allow_ftpd_full_access=1


                                At that point, vsftpd can go pretty much anywhere on the system...






                                share|improve this answer



























                                  0














                                  A slightly heavy-handed solution to allow vsftpd access anywhere, would be:



                                  setsebool -P allow_ftpd_full_access=1


                                  At that point, vsftpd can go pretty much anywhere on the system...






                                  share|improve this answer

























                                    0












                                    0








                                    0







                                    A slightly heavy-handed solution to allow vsftpd access anywhere, would be:



                                    setsebool -P allow_ftpd_full_access=1


                                    At that point, vsftpd can go pretty much anywhere on the system...






                                    share|improve this answer













                                    A slightly heavy-handed solution to allow vsftpd access anywhere, would be:



                                    setsebool -P allow_ftpd_full_access=1


                                    At that point, vsftpd can go pretty much anywhere on the system...







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Apr 1 '14 at 17:49









                                    Hunter EidsonHunter Eidson

                                    17116




                                    17116



























                                        draft saved

                                        draft discarded
















































                                        Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid


                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.

                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f122552%2fconfiguring-ftp-server-in-redhat%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

                                        Peggy Mitchell

                                        Palaiologos

                                        The Forum (Inglewood, California)