コード例 #1
0
        public static TElSimpleSFTPClient CreateClient(String uri, string privateKeyFile, string privatekeyPassword)
        {
            KeyStorage.Clear();
            var key       = new TElSSHKey();
            var keyLoaded = key.LoadPrivateKey(privateKeyFile, privatekeyPassword);

            if (keyLoaded == 0)
            {
                KeyStorage.Add(key);
            }
            else
            {
                throw new Exception(string.Format("Error loading privatekey {0}. Error: {1}", privateKeyFile, keyLoaded));
            }

            return(CreateClient(new Uri(uri), true));
        }
コード例 #2
0
        public static TElSimpleSFTPClient CreateClient(String uri, string privateKeyFile, string privatekeyPassword, string userName)
        {
            KeyStorage.Clear();
            var key       = new TElSSHKey();
            var keyLoaded = key.LoadPrivateKey(privateKeyFile, privatekeyPassword);

            if (keyLoaded == 0)
            {
                KeyStorage.Add(key);
            }
            else
            {
                throw new Exception(string.Format("Error loading privatekey {0}. Error: {1}", privateKeyFile, keyLoaded));
            }

            var uriBuilder = new UriBuilder(uri);

            if (!userName.IsNullOrWhiteSpace())
            {
                uriBuilder.UserName = userName;
            }

            return(CreateClient(uriBuilder.Uri, true));
        }