Create SFTP account programmatically on C#

mark roda

Registered
Nov 24, 2020
1
0
0
philippines
cPanel Access Level
Website Owner
I need a way to programmatically create an SFTP account that allows a user to upload to their own SFTP account.

here is an example scenario, a user comes onto a website and creates an account. then the server creates an SFTP director, username and password, and emails it to the user. then the user can start uploading files. using an sftp client.


question:

  1. is there any API in cpanel that can be called to do this? .. if yes, how?
  2. or is there any C# library or something that runs on the server that can create an SFTP folder and create credentials for the user?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,029
313
cPanel Access Level
Root Administrator
Hey there! There are cPanel API calls to create an FTP user (https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Ftp::add_ftp) but due to how cPanel users interact with SSH, sFTP is only available to the main cPanel username on the system and not additional FTP users. Since that is the case, there wouldn't be a way to do this that interfaces with the cPanel tools.

There are definitely ways to create a system user with sFTP access outside of cPanel, but that isn't something I'd be able to provide advice for as that isn't something we test and configure.