コード例 #1
0
        public SshClient OpenTunel()
        {
            var encryptedPassword = ConfigurationManager.AppSettings["SSH-Tunel-Password"];

            // in case encrypted mode is disabled
            var password = _passwordEncryptor?.Decrypt(encryptedPassword) ?? encryptedPassword;

            var tunel = new SshClient(ConfigurationManager.AppSettings["SSH-Tunel-Host"],
                                      ConfigurationManager.AppSettings["SSH-Tunel-UserName"],
                                      password);

            tunel.Connect();
            var forwardedPort = new ForwardedPortLocal(ConfigurationManager.AppSettings["SSH-Forward-Host-From"],
                                                       uint.Parse(ConfigurationManager.AppSettings["SSH-Forward-Port-From"]),
                                                       ConfigurationManager.AppSettings["SSH-Forward-Host-To"],
                                                       uint.Parse(ConfigurationManager.AppSettings["SSH-Forward-Port-To"]));

            tunel.AddForwardedPort(forwardedPort);
            forwardedPort.Start();

            return(tunel);
        }
コード例 #2
0
 public EncryptedCredential(string userName, string password, RsaCertificateEncryptor rsaCertificateEncryptor)
     : base(userName, rsaCertificateEncryptor.Decrypt(password).ToSecureString())
 {
 }