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); }
public EncryptedCredential(string userName, string password, RsaCertificateEncryptor rsaCertificateEncryptor) : base(userName, rsaCertificateEncryptor.Decrypt(password).ToSecureString()) { }