GoAdmio

ftp

Create, edit, delete, or toggle upload/download/delete permissions for a domain's FTP accounts

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/ftp manages FTP sub-accounts for a hosted domain: creating one (with its own Linux system user, chrooted-style home directory, and vsftpd permission file), editing its password, deleting it, or toggling its upload, download, and delete permissions individually.

[!WARNING] Creating or editing an account calls adduser, passwd, and usermod without sudo, unlike every other command in this script (the SQLite inserts, mkdir, chown, chmod, and systemctl restart vsftpd all use sudo). This script also has no root self-elevation check at the top, unlike several others in this reference. If this command is ever run by a caller that isn't already fully root, these specific calls can fail silently while the rest of the flow — the database row, the directory, the ownership, the "Account Created" message — still completes, leaving an FTP account that looks created but cannot actually log in, because the underlying Linux user was never made or updated. Confirm this script is only ever invoked as root before relying on it.

[!WARNING] The DisableDelete action writes its restriction to the wrong file: /etc/vsftpd/permission/$Username (the domain's own main account) instead of /etc/vsftpd/permission/$User (the sub-account you're actually targeting, used correctly by every other toggle action). As written, disabling delete for a sub-account does not restrict that sub-account at all, while potentially changing the domain's main FTP account's permissions instead. The database is still updated to say delete is disabled for that sub-account, so the recorded state and the enforced behavior disagree. See Known issues.

The call is appended to /var/log/go/ftp.log.


Quick start

# Create an FTP sub-account under a domain's www folder
/go/ftp example.com /home/example.com/www/uploads uploaduser 'MyP[DollarSign]ssw0rd'

Syntax

/go/ftp <domain> <directory> <user> <password>
/go/ftp <domain> <directory> <user> <password> edit
/go/ftp "" "" <user> "" delete
/go/ftp "" "" <user> "" EnableUpload
/go/ftp "" "" <user> "" DisableUpload
/go/ftp "" "" <user> "" EnableDownload
/go/ftp "" "" <user> "" DisableDownload
/go/ftp "" "" <user> "" EnableDelete
/go/ftp "" "" <user> "" DisableDelete

All five arguments are positional: domain, directory, user, password, action. For the toggle and delete actions, only user (and, for delete, domain, via the stored site username) actually matter — the others can be left empty, but their positions must still be there.

Form Behavior
/go/ftp <domain> <directory> <user> <password> Creates a new FTP sub-account.
... edit Changes the password for an existing sub-account.
... delete Removes the sub-account's system user and permission file, and its database row.
... EnableUpload / DisableUpload Toggles whether the account can upload files.
... EnableDownload / DisableDownload Toggles whether the account can download files.
... EnableDelete / DisableDelete Toggles whether the account can delete files — but see the warning above about DisableDelete.

Options

Argument Notes
<domain> The hosted domain; used to look up its system username and (for new accounts) to validate the directory.
<directory> Must start with /home/<domain>/ (see Known issues about how this is checked).
<user> The FTP sub-account's Linux username. Not validated for length or character rules the way hosting account usernames are (see create).
<password> See Password encoding for the placeholder scheme, and the warning above about unquoted use.
<action> One of edit, delete, EnableUpload, DisableUpload, EnableDownload, DisableDownload, EnableDelete, DisableDelete, or omitted to create a new account.

Password encoding

Because a raw password can contain shell- or URL-sensitive characters, the panel is expected to send four characters as placeholder tokens, which this command decodes before using the password:

Placeholder Becomes
[DollarSign] $
[AndSign] &
[EqualSign] =
[HashSign] #

Other characters, including a literal space, are not placeholder-encoded and are passed through as-is — see the warning about unquoted use below.


Output

Account uploaduser Created.

-----------FTP Account Info----------
Host: example.com
Username: uploaduser
Password: MyP$ssw0rd
uploaduser: FTP upload is currently disabled.
Invalid directory path.
example.com already exists.
Username uploaduser not exists.

Examples

# Create a sub-account
/go/ftp example.com /home/example.com/www/uploads uploaduser 'Str0ngP[HashSign]ss'
# Change its password
/go/ftp example.com /home/example.com/www/uploads uploaduser 'NewP[DollarSign]ss' edit
# Disable uploads for it
/go/ftp "" "" uploaduser "" DisableUpload
# Delete it
/go/ftp "" "" uploaduser "" delete

Troubleshooting

Symptom Likely cause Fix
"Account Created" is shown, but the new FTP login doesn't work The adduser/passwd steps ran without sudo and may have failed silently. See the warning above; confirm the command runs fully as root. Check id <user> afterward.
Disabling delete for a sub-account doesn't actually stop it from deleting files DisableDelete writes to the wrong permission file. See the warning above. Edit /etc/vsftpd/permission/<user> by hand to add cmds_denied=DELE,RMD until this is fixed.
The domain's own main FTP account unexpectedly can't delete files The same DisableDelete bug wrote a cmds_denied line into the domain's own permission file instead of the sub-account's. Remove the stray line from /etc/vsftpd/permission/<domain's site username> if it wasn't intended.
A brand-new account's creation prints a scary-looking integer expression expected error, but the account still gets created The existing-user check (id -u $User compared with -ge 0) produces this harmless error for a username that doesn't exist yet, which is the normal case for a new account. Cosmetic only; the account creation still proceeds.
Repeated toggling of the same permission leaves duplicate lines in the permission file Disable* actions append a line every time, without first checking whether it's already there. Harmless to vsftpd, but clean up the file by hand if it bothers you.
A password containing a space doesn't work as expected $Pass is used unquoted in openssl passwd $Pass and usermod -p $Pass, so a space splits it into separate arguments. Avoid spaces in FTP passwords, or fix the quoting.
Debian/Ubuntu FTP passwords seem to only need the first several characters to work openssl passwd with no algorithm flag defaults to a weak, legacy hash that can truncate the effective password (commonly to 8 characters). Use a stronger explicit algorithm, for example openssl passwd -6.
$Directory not exists. never seems to actually trigger By the time that check runs, the directory was already created moments earlier by an unconditional mkdir -p; this branch is effectively unreachable in normal use. Not actionable; informational only.

Details

Creating an account

  1. Confirms $User doesn't already exist as a system user (id -u).
  2. Confirms $Directory starts with /home/<domain>/ and creates it.
  3. Inserts a row into the Ftp table (storing the password as given — FTP authentication needs the literal password to hash, so it's kept recoverable, not stored as a one-way hash like a web login).
  4. Creates the Linux user rooted at $Directory and sets its password (RHEL family: adduser + passwd --stdin; Debian/Ubuntu: adduser --disabled-password + usermod -p with an openssl passwd hash).
  5. Sets ownership of the domain's home folder and 775 permissions on the new directory.
  6. Restarts vsftpd.

Editing a password

Looks up the account, then resets its password the same way as step 4 above, depending on OS.

Deleting an account

Removes the database row, deletes the system user (without -r, so the directory itself — typically a subfolder of the domain's own site files — is left in place), and removes its vsftpd permission file.

Toggling permissions

Each toggle both updates /etc/vsftpd/permission/<user> and the Ftp table's matching column, so vsftpd and GoAdmio's own records normally agree — except for DisableDelete, see the warning above.

Known issues


See also

Command Description
ftplog Report FTP activity for a domain
permission Enable or disable FTP permissions for a domain
skeleton Create or reset the skeleton FTP template account
vsftpd Install and configure the VSFTPD FTP server
fm Enable File Manager or deploy File Manager files per domain
create Create a GoAdmio account from the command line