Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: PrivateKeyAuthenticationMethod

$
0
0
I took no chances and instead just did it in code with optional parameters, like this.
Covered all 3 of my use cases this way. Seems to work.
        private static AuthenticationMethod createAuthObject(
            string _uName,
            bool _usePrivateKey,
            string _uPassword = "",
            string _ppkPassPhrase = "",
            string _ppkPath = ""
            )
        {
            PrivateKeyFile ppkFile;
            if (_usePrivateKey)
            {
                if (_ppkPassPhrase != "")
                {
                    ppkFile = new PrivateKeyFile(_ppkPath, _ppkPassPhrase);
                }
                else
                {
                    ppkFile = new PrivateKeyFile(_ppkPath);
                }
                PrivateKeyAuthenticationMethod myAuth = new PrivateKeyAuthenticationMethod(_uName, ppkFile);
                return myAuth;
            }
            else
            {
                PasswordAuthenticationMethod myAuth = new PasswordAuthenticationMethod(_uName, _uPassword);
                return myAuth;
            }
        }

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>