The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

New Account whitout FTP access

Discussion in 'General Discussion' started by cheru, Jun 5, 2009.

  1. cheru

    cheru Registered

    Joined:
    Jun 5, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi. I want to create new accounts but whitout FTP access. This can be done trought the hooks? How can I do this task?

    Many thanks
     
    #1 cheru, Jun 5, 2009
    Last edited: Jun 5, 2009
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Creating cPanel user accounts that do not have FTP access is not natively supported by cPanel/WHM at this time. Nor am I aware of any API/hook functionality that would let you implement such limitations.

    If you do not want any users to have FTP access, try disabling the FTP server. If you want the user to have no access to the files on their account, be sure to disable File Manager, Legacy File Manager and turn off cpdavd (Web Disk server) as well.
     
  3. cheru

    cheru Registered

    Joined:
    Jun 5, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I 've disabled File Manager, Legacy File Manager, turned off cpdavd and changed the user package (I leave checked only the mail features). But when I create a new user the FTP access is still allowed...
    I modify the hook /scripts/postwwwacctuser and I added this line to solve the problem:

    echo $1 >> /etc/ftpusers

    And it's all. The final solution.

    Thanks for your help
     
  4. fineline

    fineline Active Member

    Joined:
    Apr 10, 2006
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    Disable users FTP

    If your using Pure-FTP it's very simple to disable a users account.
    Cpanel should add it as a feature if you ask me.

    if you look at /usr/sbin/pureauth

    you see this in the code

    Code:
    # Create ftpusers array
    if ( -e '/etc/ftpusers' && !-z '/etc/ftpusers' ) {
        open my $ftpusers_fh, '<', '/etc/ftpusers';
        my @ftpusers = <$ftpusers_fh>;
        close $ftpusers_fh;
        @ftpusers = grep { s/[\r\n\s]//g } @ftpusers;
    
        # disallow accounts in ftpusers
        if ( any( sub { lc($acctowner) eq lc($_) }, @ftpusers ) ) {
            failed_auth();
        }
    }
    
    i just make a file
    /etc/ftpusers

    add the accounts username in the file
    Then they can no longer FTP into their account.

    Other account can still FTP in fine. So i would say it works :D
     
  5. mohamed81

    mohamed81 Registered

    Joined:
    Feb 11, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    To disallow specific users instead of disallowing all users of an account

    Edit (/usr/sbin/pureauth)

    Search for

    Code:
    # Create ftpusers array
    if ( -e '/etc/ftpusers' && !-z '/etc/ftpusers' ) {
        open my $ftpusers_fh, '<', '/etc/ftpusers';
        my @ftpusers = <$ftpusers_fh>;
        close $ftpusers_fh;
        @ftpusers = grep { s/[\r\n\s]//g } @ftpusers;
    
        # disallow accounts in ftpusers
        if ( any( sub { lc($acctowner) eq lc($_) }, @ftpusers ) ) {
            failed_auth();
        }
    }

    Add this CODE before or after


    Code:
    # Create ftpusers2 array
    if ( -e '/etc/ftpusers2' && !-z '/etc/ftpusers2' ) {
        open my $ftpusers_fh, '<', '/etc/ftpusers2';
        my @ftpusers2 = <$ftpusers_fh>;
        close $ftpusers_fh;
        @ftpusers2 = grep { s/[\r\n\s]//g } @ftpusers2;
    
        # disallow users in ftpusers2
        if ( any( sub { lc($user) eq lc($_) }, @ftpusers2 ) ) {
            failed_auth();
        }
    }
    Or you can just change the $acctowner to $user in the original code.

    Save

    create file (/etc/ftpusers2) and add the disallowed usernames

    The main user (username) or (sub_user@domain.com)

    I use this to disallow FTP for the main user and force him to use SFTP

    However, the file (/usr/sbin/pureauth) might be replaced by future updates.

    Thank you for your help
     
    #5 mohamed81, Feb 11, 2010
    Last edited: Feb 11, 2010
  6. sehh

    sehh Well-Known Member

    Joined:
    Feb 11, 2006
    Messages:
    579
    Likes Received:
    5
    Trophy Points:
    18
    Location:
    Europe
    Does the above work for sftp as well?
     
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    All of the above is for FTP. SFTP (SSH File Transfer) works via SSH instead, so it is not influenced by FTP configurations. However, FTPS (FTP over SSL/TLS) does work via FTP and would be influenced by the above.
     
Loading...

Share This Page