My quest for SSH within PowerShell revisited!

I seem to be in a very PowerShell mood these past couple of days... hence yet another PSH post. I'd expect at least yet another post once I figure out a CTP2 eventing issue I'm trying to work around. Then... I will most likely move to some Identity Management stuff I have been wanting to talk about. Or... maybe I will talk about some Vista security stuff. We shall see

Anyhow, you may or may not remembermy last attemptin my quest for SSH support directly within PSH. Needless to say my "feedback" has gone nowhere with the product group. I still really think SSH support should be native to either PSH or at least the .NET Framework. But... you can only wish for something so long before you turn to other solutions.

Well... I had to update a script of mine that was using a similar WinSCP solution to SCP files from a set of Windows CAs to CDP points that were hosted by a bunch of Sun boxes (that's a long sentence). Anyhow... I never did like the external .exe solution. So... I looked back into using an assembly to take care of the SSH dirty work.

At first, I tried some commercial products, and couldn't really get anything working correctly. Frustrated, I turned back SharpSSH. For some strange reason, it worked just fine this time around. I suspect the difference was the fact I pulled the execution of this script off of the CAs and onto a Utility server. I tend to deploy CAs using a very customized Baseline Security Policy that turns, disables, and tweaks a lot of stuff. :>)

The following code summarizes how to connect to a remote host using SCP:

Add-Type -Path "$MCDPResources\DiffieHellman.dll"

Add-Type -Path "$MCDPResources\Org.Mentalis.Security.dll"

Add-Type -Path "$MCDPResources\Tamir.SharpSSH.dll"

$scpClient = New-Object Tamir.SharpSsh.scp "$HostName", "$UserName", "$Password"

$scpClient.Connect()

Once you have connected you would use the Put and Get methods to perform your file transfers. Obviously, the script is a lot more complicated... In addition, I'm trying to use eventing for the file transfers, key based authentication, and some other neat things working. I will be sure to share.

Join the Network World communities onFacebookandLinkedInto comment on topics that are top of mind.

Copyright © 2008Raybet2

它的工资调查:结果是在