I am developing a script that makes use for the SSH.NET library. I find it to be an excellent library, simple and straight forward.
Currently, in PowerShell, I perform the following:
$SSH = New-Object -TypeName Renci.SSHNet.SSHClient -ArgumentList $VCIP, $UserName, $Password $SSH.Connect()
This works very well, and in my current use cause I use the RunCommand method to get information back from the client.
My issue is that the above requires that plain text credentials are passed. I am connecting to a large number of devices as part of an automated task. Can anybody help me store and use credentials in a non-readable format?
I was thinking of doing something like this to store the password:
(Get-Credential).Password | ConvertFrom-SecureString | set-content c:\temp\test.creds
and then using it later:
= Get-Content c:\temp\test.creds | ConvertTo-SecureString
Does anybody have any suggestions?
P.S. If anybody is wondering how to use the .NET 4.0 component in PowerShell, you need a PowerShell config file:
- Create powershell.exe.config %windir%\System32\WindowsPowerShell\v1.0
- In the config file, add the following XML.
- Restart PowerShell.
Thanks very much. Regards,