2017-07-06 64 views
1

我一直在使用Windows Server 2012 R2,并且我为SFTP使用了bitvise SSH,并且我想在我的应用程序中以编程方式创建SFTP用户。以编程方式使用c#创建SFTP用户

我想要做的是当任何用户注册到应用程序中,然后应用程序将为新创建的文件夹创建一个新的文件夹和SFTP凭据。因此,每个用户都可以访问他们的SFTP凭证,以便将文件上传到其关联的文件夹。

我可以找到动态创建FTP用户的解决方案,但我想创建SFTP用户。

问题:是否有可能使用c#创建SFTP用户?如果是那么如何?

+0

https://www.bitvise.com/ssh-server-guide-scriptable说:“Bitvise SSH Server提供了一个文本配置实用程序,BssCfg,这对于在大规模安装中管理SSH服务器非常有用,它还附带了一个配置COM对象BssCfgManip,可用于使用任何支持COM的语言来配置SSH服务器,但特别适用于PowerShell。您应该可以使用C#中的COM对象。请注意,SSH/SFTP用户确实是本机的Windows用户,具有Bitvise可以帮助控制的某些权限。 – ADyson

回答

0

可以使用C#如创建SFPT用户:

var cfg = new CBssCfg726("BssCfg726.BssCfg726"); 

cfg.SetSite("Bitvise SSH Server"); 

cfg.LoadServerSettings(); 


[email protected] ="Virtual Account Name"; 
[email protected]("Password"); 
[email protected] = "Virtual Users"; 

//if already virtAccountsEx then first delete... 
for (uint i = 0; i < cfg.settings.access.virtAccountsEx.count; i++) { 
    if (cfg.settings.access.virtAccountsEx.GetItem(i).virtAccount == "Virtual Account Name") { 
     cfg.settings.access.virtAccountsEx.Erase(i); 
    } 
} 
[email protected][email protected] = "127.0.0.1"; 
[email protected][email protected] = 80; 
[email protected][email protected] = "Default"; 
[email protected] = cfg.DefaultYesNo.yes; 
[email protected](); 
[email protected]@new.sfsMountPath = "/"; 
[email protected]@new.realRootPath = "Path to folder"; 
[email protected]mmit(); 
[email protected].NewCommit(); 
cfg.settings.access.virtAccountsEx.NewCommit(); 
cfg.SaveServerSettings(); 
相关问题