本文介绍了是否可以使用c#创建SFTP(非FTP)用户?如果是的话该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过c#代码创建SFTP(非FTP)用户帐户.是否可以通过我的代码创建sftp用户?我将bitvise SSH服务器用作sftp服务器,并将filezilla服务器用作ftp服务器,现在我想为我的不同员工创建不同的用户,以便他们都可以访问我的服务器上的不同文件夹,并且无法可以访问彼此的路径(文件夹).有人可以通过c#代码在sftp中创建用户吗?

Creating SFTP(Not FTP) user account through c# code.Is this possible to create sftp users by my code? I'm using bitvise SSH server as my sftp server, and filezilla server as my ftp server, now I want to create different users for my different employees so that they all would have access of different folders on my server and could not be able to access each others path (folders).Can anyone have some idea of user creation in sftp by c# code?

推荐答案

1)对于使Windows咬SSH服务器帐户

1) For make windows bitvise ssh server Account

public static int Main(string[] args)
    {
        try
        {
            var cfg = new CBssCfg726("BssCfg726.BssCfg726");
            cfg.SetSite("Bitvise SSH Server");
            cfg.LockServerSettings();
            cfg.LoadServerSettings();

            [email protected] = "Domain_Name";
            [email protected] = "Account_Name";
            [email protected] = cfg.DefaultYesNo.yes;
            [email protected]();
            [email protected][email protected] = "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服务器帐户

2) For make virtual bitvise ssh server account

private void AssignPowerSchoolCredentials()
    {
        try
        {
            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][email protected] = "/";
            [email protected][email protected] = "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)用户?如果是的话该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 05:59