Geeks With Blogs

Lance's TextBox

In the past I gave examples of using the get-ftp and send-ftp cmdlets for PowerShell, but recently a user pointed out that I didn’t show any examples of public key authentication using the cmdlets.

Of course the –ssh flag tells the get-ftp and send-ftp cmdlets to use SSH (instead of plain text FTP, or an SSL connection which is turned on with the –ssl flag).  For SSH connections, the AuthMode parameter determines what type of SSH authentication to perform – in this case that will be “publickey”.  The “Cert” parameters (-CertStoreType, –CertStore, –CertPassword, and –CertSubject) are used to point to the specific private key you’d like to use for authentication.  If you’re using a pem key, –CertStoreType will be “pemkey”.  Use –CertStore to point to the actual file itself, and –CertPassword will be the password required to open the file.  -CertSubject is used to refer to the specific certificate in the file – or just use “*” to pick the first (or only) certificate in the file.

get-ftp -server 10.0.1.159 -user lancer -ssh -AuthMode publickey -CertStoreType pemkey -CertStore C:\id_rsa -CertPassword (read-host -assecurestring "Enter Password") -CertSubject "*"

 

Technorati Tags: , ,
Posted on Wednesday, June 25, 2008 10:29 AM Programming , PowerShell | Back to top


Comments on this post: NetCmdlets SFTP - Public Key Authentication in PowerShell

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Lance Robinson | Powered by: GeeksWithBlogs.net