At line 1 changed one line |
If you are reading this, you are likely wanting a well documented published API to reference. You won't find that here. Its my opinion that the admin WebInterface provides a working example that is easily watched to see the commands its issuing for the documentation. If you want to know how to make a user using a web call, enable the network monitoring in Chrome/Safari/FireBug and make a user. Then its all detailed out. |
(File Transfer API can be found here: [APIFileTransfer].) |
!!!Admin API Tool: (as of CrushFTP v8.1)\\ |
First launch the command line tool passing it the arguments as an admin username and password (CrushTunnel.jar is located in your WebInterface folder):\\ |
{{{ |
java -jar CrushTunnel.jar https://crushamdin:password@yourserver.com/ |
}}}\\ |
Now you can issue the user command to add a user, assign a VFS.\\ |
{{{ |
user user_add MainUsers user3 password=password |
user user_update MainUsers user3 email=support@CrushFTP.com first_name=John last_name=Doe |
user vfs_add MainUsers user3 path=/home/ privs=(read)(write)(resume)(delete)(view) url=file://home/ name=home |
user vfs_add MainUsers user3 path=/home/subfolder/ privs=(read)(resume)(view) |
user vfs_delete MainUsers user3 path=/home/ name=home |
user vfs_delete MainUsers user3 path=/home/subfolder/ privs=(read)(resume)(view) |
user user_delete MainUsers user3 |
user list MainUsers users |
user list MainUsers groups |
user list MainUsers inheritance |
}}}\\ |
Where:\\ |
__path__ is the FTP style path to the folder, relative to the user's virtual root, "/". If it's single VFS , then path is to be "/" indeed, otherwise we'll create a Virtual root item, read only, the true VFS will be added below.\\ |
\\ |
__privs__ the user VFS folder permissions, can be any combination of __(read)(write)(view)(delete)(deletedir)(makedir)(rename)(resume)(share)(slideshow)(invisible)(ratio)(replicate)(locked)__, for details see our user [VFS] related docs page.\\ |
\\ |
__url__ the true URL pointing to the folder itself. \\ |
\\ |
__Managing Server's Files__:\\ |
\\ |
These commands require an admin user. They allow administrators to perform file operations directly on the server’s file system, such as createing, renaming, or deleting folders. Use them with caution, as changes affect actual server data.\\ |
Template:\\ |
{{{ |
user adminAction <<action>> <<path>> <<name>> |
or |
user adminAction <<action>> <<path>> <<name>> <<new name>> |
}}}\\ |
Examples:\\ |
{{{ |
user adminAction newFolder /home/ test_subfolder |
user adminAction duplicateItem /home/ test_subfolder |
user adminAction renameItem /home/ test_subfolder test_subfolder_new |
user adminAction deleteItem /home/ test_subfolder_new |
}}}\\ |
\\ |
__Managing User Folder Permissions:__\\ |
\\ |
Template:\\ |
{{{ |
user <<action>> <<user connection group>> <<username>> path=<<the path>> privs=<<the custom privs>> |
}}}\\ |
\\ |
{{{ |
user vfs_add MainUsers user3 path=/home/subfolder/ privs=(read)(resume)(view) |
}}}\\ |
It is used to give a specific user (user3) access to a subfolder within an existing (VFS). It does not replace the user’s existing folder access, but simply adds a new set of permissions—allowing user3 to have different permissions specifically for the /home/subfolder/ location.\\ |
\\ |
{{{ |
user vfs_delete MainUsers user3 path=/home/subfolder/ privs=(read)(resume)(view) |
}}}\\ |
It is used to remove specific permissions for user3 on the /home/subfolder/ location. It does not remove the entire folder access, but only the specified permissions.\\ |
\\ |
__Managing Groups and Inheritance:__\\ |
You can also assign groups, and inheritance:\\ |
{{{ |
user group_add MainUsers user3 groupname |
user inheritance_add MainUsers user3 groupname |
}}} |
Or remove a user from a group or inheritance:\\ |
{{{ |
user group_delete MainUsers user3 groupname |
user inheritance_delete MainUsers user3 groupname |
}}}\\ |
\\ |
__Managing allowed protocols__:\\ |
You can use the user API call in CrushTunnel.jar to set the field: allowed_protocols to configure Port restrictions\\ |
{{{ |
ftp:0,ftps:0,sftp:0,http:0,https:0,webdav:0, |
}}}\\ |
That is the default, but if you only wanted to allow sftp and https, you could do: |
sftp:0,https:0,\\ |
\\ |
__Managing Jobs:__\\ |
Its also possible to tell the server to run a Job if you want to remote control jobs:\\ |
{{{ |
job remote MyFindJob param1=test param2=test |
}}}\\ |
\\ |
!!!Alternative methods using raw CURL commands:\\ |
If you are reading this, you are likely wanting a well documented published API to reference. You won't find that here. Its our opinion that the admin WebInterface provides a working example that is easily watched to see the commands its issuing for the documentation. If you want to know how to make a user using a web call, enable the network monitoring in Chrome/Safari/FireFox/Edge and make a user. Then its all detailed out in the network requests created. |
At line 3 changed one line |
I will provide one example here to get you started though, and I may add to this by user request if things are not clear enough. |
Here are a few examples here to get you started though, and we may add to this list in the future too. |
At line 92 added 3 lines |
''(The attachments tab at the top contains the sample files.)''\\ |
\\ |
\\ |
At line 6 changed one line |
Making a new User for the User Manager |
!Registering CrushFTP service from command line. |
At line 9 changed one line |
Builds a brand new user, or replaces and existing one entirely. |
Uses a command to register the CrushFTP license key in case you need to deploy on multiple machines E3 specific, and need to automate the registration. |
The spaces and special characters need to be URL encoded |
At line 103 added 11 lines |
curl -d command=registerCrushFTP -d registration_name=MY%2520NAME -d registration_email=MYNAME%2540MYEMAIL.COM.EXAMPLE -d registration_code=my_reg_code -u crushadmin:'password' http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)'' |
\\ |
---- |
!Making a new User with VFS |
---- |
|
Builds a brand new user, or replaces an existing one entirely. |
|
{{{ |
At line 14 changed one line |
(long line, so get it all) |
''(long line, so get it all)'' |
At line 17 changed one line |
Updating a user in the User Manager |
!Delete a user |
At line 121 added 7 lines |
{{{ |
curl -d command=setUserItem -d data_action=delete -d xmlItem=user -d serverGroup=MainUsers -d username=curl_user http://crushadmin:pass@127.0.0.1:8080/ |
}}} |
\\ |
---- |
!Updating a user |
---- |
At line 25 changed one line |
(long line, so get it all) |
''(long line, so get it all)'' |
\\ |
Updating a user with certain properties, the missing/updated xml keys can be supplied in line, below example sets the password as the literal "thisismypass" |
\\ |
{{{ |
curl -d command=setUserItem -d data_action=update -d xmlItem=user -d serverGroup=MainUsers -d username=curl_user --data-urlencode 'user=<?xml+version="1.0"+encoding="UTF-8"?>+<user+type="properties"><password>thisismypass</password></user>' http://crushadmin:pass@127.0.0.1:8080/ |
}}} |
''(long line, so get it all)'' |
\\ |
\\ |
!Update/add to VFS of a user\\ |
This will update the VFS, either replacing an existing item, or adding a new item if it doesn't exist:\\ |
{{{ |
curl -d command=setUserItem -d data_action=update_vfs -d xmlItem=user -d serverGroup=MainUsers -d username=user1 -d vfs_items@vfs_items.XML -d permissions@permissions.XML -u crushadmin:passw http://127.0.0.1:8080/ |
}}}\\ |
''(long line, so get it all)''\\ |
\\ |
Add a specific permission to a subfolder:\\ |
{{{ |
curl -d command=setUserItem -d data_action=update_vfs -d xmlItem=user -d serverGroup=MainUsers -d username=user1 -d permissions@permissions.XML -u crushadmin:passw http://127.0.0.1:8080/ |
}}}\\ |
''(long line, so get it all)''\\ |
\\ |
!Delete VFS item from a user\\ |
This will remove a VFS item (so don't pass in a full permissions or vfs_items object or you would remove everything):\\ |
{{{ |
curl -d command=setUserItem -d data_action=update_vfs_remove -d xmlItem=user -d serverGroup=MainUsers -d username= user1 -d vfs_items@vfs_items.XML -d permissions@VFS.XML -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)'' |
\\ |
\\ |
!!Groups and Inheritance:\\ |
\\ |
Add some users into a group, it will make the group if it doesn't exist:\\ |
{{{ |
curl -d command=setUserItem -d xmlItem=groups -d serverGroup=MainUsers -d data_action=add -d group_name=MyGroup -d usernames="user1;user2" -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)''\\ |
\\ |
Delete users from a group:\\ |
{{{ |
curl -d command=setUserItem -d xmlItem=groups -d serverGroup=MainUsers -d data_action=delete -d group_name=MyGroup -d usernames="user1;user2" -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)''\\ |
\\ |
Delete an entire group:\\ |
{{{ |
curl -d command=setUserItem -d xmlItem=groups -d serverGroup=MainUsers -d data_action=delete -d group_name=MyGroup -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)''\\ |
\\ |
Add some users to inheritance, it will make the inheritance if it doesn't exist:\\ |
{{{ |
curl -d command=setUserItem -d xmlItem=inheritance -d serverGroup=MainUsers -d data_action=add -d inheritance_name=AdminTemplate -d usernames="user1;user2" -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)''\\ |
\\ |
Delete users from an inheritance item:\\ |
{{{ |
curl -d command=setUserItem -d xmlItem=inheritance -d serverGroup=MainUsers -d data_action=delete -d inheritance_name=AdminTemplate -d usernames="user1;user2" -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)''\\ |
\\ |
Delete an entire inheritance:\\ |
{{{ |
curl -d command=setUserItem -d xmlItem=inheritance -d serverGroup=MainUsers -d data_action=delete -d inheritance_name=AdminTemplate -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
''(long line, so get it all)''\\ |
\\ |
!!Job:\\ |
\\ |
Run a remote job on the server:\\ |
{{{ |
curl -d command=testJobSchedule -d scheduleName=MyFindJob -d async=false -d response_type=all -d myparam1=happy -u crushadmin:pass http://127.0.0.1:8080/ |
}}} |
|
Run a job via command line: |
{{{ |
java -jar CrushTunnel.jar inline_script "connect https://admin:pass@server.com/;job remote MyFindJob param1=test;quit;" |
}}} |
or from an execute task of CrushTask do: |
{{{ |
separator: ~ |
command: java |
Parameters: -jar~CrushTunnel.jar~inline_script~connect https://admin:pass@server.com/;job remote MyFindJob param1=test;quit; |
}}} |
''(long line, so get it all)''\\ |
\\ |
!!IP Restrictions:\\ |
\\ |
Unban an ip (only for full admin users):\\ |
\\ |
{{{ |
curl -d command=unban -d ip=192.168.0.5 -u crushadmin:pass http://127.0.0.1:8080/ |
}}}\\ |
\\ |
\\ |
Modify IP restrictions (only for full admin users):\\ |
\\ |
{{{ |
curl -d command=modifyIpRestrictions -d start_ip=192.168.0.5 -d stop_ip=192.168.0.5 -d type=A -d method=add -u admin:pass http://127.0.0.1:9090 |
}}}\\ |
\\ |
{{{ |
curl -d command=modifyIpRestrictions -d start_ip=192.168.0.5 -d stop_ip=192.168.0.5 -d type=A -d method=delete -u admin:pass http://127.0.0.1:9090 |
}}}\\ |
\\ |
!!Update:\\ |
\\ |
Perform update: |
{{{ |
DMZ: |
curl -d command=updateNow -u crushadmin:pass https://myserver.com/dmz_instance_name/ |
|
INTERNAL: |
curl -d command=updateNow -u crushadmin:pass https://myserver.com/ |
}}} |