是否可以使用 c# 创建 SFTP(Not FTP) 用户?如果是那么怎么办?
Is it possible to create SFTP(Not FTP) user using c#? If it is then how?
正在通过 C# 代码创建 SFTP(不是 FTP)用户帐户。
是否可以通过我的代码创建 sftp 个用户?我使用 bitvise SSH 服务器作为我的 sftp 服务器,使用 filezilla 服务器作为我的 ftp 服务器,现在我想为不同的员工创建不同的用户,以便他们都可以访问不同的文件夹在我的服务器上,无法访问彼此的路径(文件夹)。任何人都可以通过 c# 代码在 sftp 中创建用户吗?
1) 制作 windows bitvise ssh 服务器帐户
public static int Main(string[] args)
{
try
{
var cfg = new CBssCfg726("BssCfg726.BssCfg726");
cfg.SetSite("Bitvise SSH Server");
cfg.LockServerSettings();
cfg.LoadServerSettings();
cfg.settings.access.winAccountsEx.@new.winDomain = "Domain_Name";
cfg.settings.access.winAccountsEx.@new.winAccount = "Account_Name";
cfg.settings.access.winAccountsEx.@new.loginAllowed = cfg.DefaultYesNo.yes;
cfg.settings.access.winAccountsEx.@new.xfer.mountPointsEx.Clear();
cfg.settings.access.winAccountsEx.@new.xfer.mountPointsEx.@new.realRootPath = "C:\Sftp\User";
cfg.settings.access.winAccountsEx.@new.xfer.mountPointsEx.NewCommit();
cfg.settings.access.winAccountsEx.NewCommit();
cfg.UnlockServerSettings();
cfg.SaveServerSettings();
return 0;
}
catch (Exception ex)
{
throw ex;
}
}
2) 用于创建虚拟 bitvise ssh 服务器帐户
private void AssignPowerSchoolCredentials()
{
try
{
var cfg = new CBssCfg726("BssCfg726.BssCfg726");
cfg.SetSite("Bitvise SSH Server");
cfg.LoadServerSettings();
cfg.settings.access.virtAccountsEx.@new.virtAccount = "Virtual_Account_name";
cfg.settings.access.virtAccountsEx.@new.virtPassword.Set("Password");
cfg.settings.access.virtAccountsEx.@new.group = "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);
}
}
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.@new.targetHost = "127.0.0.1";
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.@new.targetPort = 80;
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.@new.proxyProfile = "Default";
cfg.settings.access.virtAccountsEx.@new.loginAllowed = cfg.DefaultYesNo.yes;
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.Clear();
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.@new.sfsMountPath = "/";
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.@new.realRootPath = "Folder_path";
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.NewCommit();
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.NewCommit();
cfg.settings.access.virtAccountsEx.NewCommit();
cfg.SaveServerSettings();
}
catch (Exception ex)
{
throw ex;
}
}
正在通过 C# 代码创建 SFTP(不是 FTP)用户帐户。 是否可以通过我的代码创建 sftp 个用户?我使用 bitvise SSH 服务器作为我的 sftp 服务器,使用 filezilla 服务器作为我的 ftp 服务器,现在我想为不同的员工创建不同的用户,以便他们都可以访问不同的文件夹在我的服务器上,无法访问彼此的路径(文件夹)。任何人都可以通过 c# 代码在 sftp 中创建用户吗?
1) 制作 windows bitvise ssh 服务器帐户
public static int Main(string[] args)
{
try
{
var cfg = new CBssCfg726("BssCfg726.BssCfg726");
cfg.SetSite("Bitvise SSH Server");
cfg.LockServerSettings();
cfg.LoadServerSettings();
cfg.settings.access.winAccountsEx.@new.winDomain = "Domain_Name";
cfg.settings.access.winAccountsEx.@new.winAccount = "Account_Name";
cfg.settings.access.winAccountsEx.@new.loginAllowed = cfg.DefaultYesNo.yes;
cfg.settings.access.winAccountsEx.@new.xfer.mountPointsEx.Clear();
cfg.settings.access.winAccountsEx.@new.xfer.mountPointsEx.@new.realRootPath = "C:\Sftp\User";
cfg.settings.access.winAccountsEx.@new.xfer.mountPointsEx.NewCommit();
cfg.settings.access.winAccountsEx.NewCommit();
cfg.UnlockServerSettings();
cfg.SaveServerSettings();
return 0;
}
catch (Exception ex)
{
throw ex;
}
}
2) 用于创建虚拟 bitvise ssh 服务器帐户
private void AssignPowerSchoolCredentials()
{
try
{
var cfg = new CBssCfg726("BssCfg726.BssCfg726");
cfg.SetSite("Bitvise SSH Server");
cfg.LoadServerSettings();
cfg.settings.access.virtAccountsEx.@new.virtAccount = "Virtual_Account_name";
cfg.settings.access.virtAccountsEx.@new.virtPassword.Set("Password");
cfg.settings.access.virtAccountsEx.@new.group = "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);
}
}
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.@new.targetHost = "127.0.0.1";
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.@new.targetPort = 80;
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.@new.proxyProfile = "Default";
cfg.settings.access.virtAccountsEx.@new.loginAllowed = cfg.DefaultYesNo.yes;
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.Clear();
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.@new.sfsMountPath = "/";
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.@new.realRootPath = "Folder_path";
cfg.settings.access.virtAccountsEx.@new.xfer.mountPointsEx.NewCommit();
cfg.settings.access.virtAccountsEx.@new.fwding.srvSideC2S.ipv4Ex.NewCommit();
cfg.settings.access.virtAccountsEx.NewCommit();
cfg.SaveServerSettings();
}
catch (Exception ex)
{
throw ex;
}
}