public void Authenticate() { string privateKey = _loginSettings.Get <string>(SftpLoginInfo.PrivateKey); string userName = _loginSettings.Get <string>(LoginInfo.UserName); string password = _loginSettings.Get <string>(LoginInfo.Password); SecureShellPrivateKey key; if (string.IsNullOrEmpty(privateKey)) { key = null; } else { string keypassword = _view.AskForPassword("Please provide password for the key"); if (string.IsNullOrEmpty(password)) { _view.ShowError(Messages.NoPassword); _controller.Disconnect(); return; } // try to load the key. try { key = new SecureShellPrivateKey(privateKey, keypassword); } catch (Exception exc) { Util.ShowError(exc); _controller.Disconnect(); return; } } _client.AuthenticateAsync(userName, password, key); }