2019-04-29 16:05:43 +02:00
[![AppVeyor branch ](https://img.shields.io/appveyor/ci/OCram85/PSCredentialStore/master.svg?style=plastic "Master Branch Build Status" )](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master)
2017-11-15 10:17:23 +01:00
[![AppVeyor tests branch ](https://img.shields.io/appveyor/tests/OCram85/PSCredentialStore/master.svg?style=plastic "Pester Tests Results" )](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master/tests)
2018-03-09 14:02:51 +01:00
[![Coveralls github ](https://img.shields.io/coveralls/github/OCram85/PSCredentialStore.svg?style=plastic "Coveralls.io Coverage Report" )](https://coveralls.io/github/OCram85/PSCredentialStore?branch=master)
2017-11-15 10:17:23 +01:00
[![PowerShell Gallery ](https://img.shields.io/powershellgallery/v/PSCredentialStore.svg?style=plastic "PowershellGallery Published Version" )](https://www.powershellgallery.com/packages/PSCredentialStore)
2019-04-29 16:05:43 +02:00
[![PowerShell Gallery ](https://img.shields.io/powershellgallery/vpre/PSCredentialStore.svg?label=latest%20preview&style=plastic "PowershellGallery Latest Preview Version" )](https://www.powershellgallery.com/packages/PSCredentialStore)
2017-11-15 10:17:23 +01:00
[![PowerShell Gallery ](https://img.shields.io/powershellgallery/dt/PSCredentialStore.svg?style=plastic "PowershellGallery Downloads" )](https://www.powershellgallery.com/packages/PSCredentialStore)
![forthebadge ](http://forthebadge.com/images/badges/built-with-love.svg )
![forthebadge ](http://forthebadge.com/images/badges/for-you.svg )
2017-09-21 13:32:15 +02:00
2019-05-10 10:12:26 +02:00
![social-logo ](/assets/social-logo.png )
2019-04-29 16:05:43 +02:00
:key: General
2017-09-21 13:32:15 +02:00
=======
2019-04-29 16:05:43 +02:00
The PSCredentialStore is a simple credential manager for `PSCredential` objects. It stores PSCredentials in a simple json
2017-10-16 19:47:19 +02:00
file. You can choose between a private and shared credential store. The private one exists in your profile and can
2017-09-21 13:32:15 +02:00
ony accessed by your account on the same machine. The shared store enables you to use different credentials for your
2017-10-16 19:47:19 +02:00
scripts without exposing them as plain text.
2017-09-21 13:32:15 +02:00
PSCredentialStore was developed to simplify the delegation of complex powershell scripts. In this case you often
need to store credentials for non interactive usage like in scheduled tasks.
2019-04-29 16:05:43 +02:00
Starting with version `1.0.0` PSCredential uses Pfx certificates fo encryption. You can use Pfx certificate files
or certificates stored in the certificate store.
2018-03-09 14:02:51 +01:00
For more details read the [about_PSCredentialStore ](/docs/about_PSCredentialStore.md ) page on github or via CLI with
`Get-Help about_PSCredentialStore` .
2017-09-21 13:32:15 +02:00
2019-04-29 16:05:43 +02:00
You can find the [reference ](/docs/PSCredentialStore.md ) in the /docs/ path as well.
2019-01-16 12:55:29 +01:00
2019-04-29 16:05:43 +02:00
:vulcan_salute: Requirements
============
2019-01-16 12:55:29 +01:00
2019-04-29 16:05:43 +02:00
- PowerShell >= `5.1`
- .NET Framework >= `4.6` or .NET Core >= `1.0`
2019-01-16 12:55:29 +01:00
2019-10-18 13:47:10 +02:00
:bomb: About Security
============
>This section explains some security topics and the the design decisions we made to balance the usage and security needs.
2020-01-23 11:37:36 +01:00
To be able to delegate `PSCredentials` objects we can't exclusively rely on the `SecureString` cmdlets. You can't
decrypt and reuse such credentials from a different user account or even machine. This is caused by automatically
generated encryption key which, is used create a `Secure String` based encrypted string.
2019-10-18 13:47:10 +02:00
2020-01-23 11:37:36 +01:00
In order to delegate a password, while still using the underlying security framework, we have to provide a custom
2019-10-18 13:47:10 +02:00
encryption key. This leads to the fact, that everyone who has access to the key could encrypt or decrypt your data.
2020-01-23 11:37:36 +01:00
So we decided to use the public and private keys from valid certificates as part of the custom encryption keys to encrypt your data.
2019-10-18 13:47:10 +02:00
2020-01-23 11:37:36 +01:00
This means clearly: Everyone who has access to the `CredentialStore` needs also access to the certificate file to work with it.
2019-10-18 13:47:10 +02:00
Keep in mind you need to secure the access with your NTFS file permissions to avoid unwanted usage. Another option is
to import the certificate into your certification vaults of you operating system. In this case you can grand the
permission to the certificates itself.
Here is s brief hierarchy description of the certificate location: *(First match wins)*
| CredentialStore Type | Certificate Location |
| -------------------- | ---------------------- |
| Private | `CurrentUser` \\`My` |
| Shared (Windows) | `CurrentUser` \\`My` |
| | `LocalMachine` \\`Root` |
| Shared (Linux) | `LocalMachine` \\`My` |
| | `LocalMachine` \\`Root` |
2019-04-29 16:05:43 +02:00
:hammer_and_wrench: Installation
2017-09-21 13:32:15 +02:00
============
2019-04-29 16:05:43 +02:00
:artificial_satellite: PowerShellGallery.com (Recommended Way)
2017-09-21 13:32:15 +02:00
---------------------------------------
2019-01-16 12:55:29 +01:00
* Make sure you use PowerShell 5.1 or higher with `$PSVersionTable` .
* Use the builtin PackageManagement and install with: `Import-Module PowerShellGet; Install-Module 'PSCredentialStore' -Repository 'PSGallery'`
* Additionally use the `-AllowPrerelease` switch until we publish the final release!
2017-09-21 13:32:15 +02:00
* Done. Start exploring the Module with `Import-Module PSCredentialStore ; Get-Command -Module PSCredentialStore`
2019-04-29 16:05:43 +02:00
:building_construction: Manual Way
2017-09-21 13:32:15 +02:00
----------
* Take a look at the [Latest Release ](https://github.com/OCram85/PSCredentialStore/releases/latest ) page.
* Download the `PSCredentialStore.zip` .
2017-10-16 19:47:19 +02:00
* Unpack the zip file and put it in your Powershell module path.
2017-09-21 13:32:15 +02:00
* Don't forget to change the NTFS permission flag in the context menu.
* Start with `Import-Module PSCredentialStore`
2019-04-29 16:05:43 +02:00
:sparkles: Quick Start
2017-09-21 13:32:15 +02:00
-----------
2017-10-16 19:47:19 +02:00
**1.** First we need a blank credential store. You can decide between a *private* or *shared* store. The private
2017-09-21 13:32:15 +02:00
Credential Store can only be accessed with your profile on the machine you created it.
2019-04-29 16:05:43 +02:00
Starting with version `1.0.0` you can decide the storage type of your fresh created certificate. As default
PSCredentialStore creates a new pfx certificate file beside the credential store itself. Optionally you can provide
the parameter `-UseCertStore` . This imports the new certificate in the user or machine certificate store as well.
2017-09-21 13:32:15 +02:00
```powershell
2017-10-16 19:47:19 +02:00
# Private credential store
2017-09-21 13:32:15 +02:00
New-CredentialStore
2019-04-29 16:05:43 +02:00
# Private credential store with certificate store usage
New-CredentialStore -UseCertStore
# Shared credential store
2017-09-21 13:32:15 +02:00
New-CredentialStore -Shared
2019-04-29 16:05:43 +02:00
#Shared credential store in custom location
2017-09-21 13:32:15 +02:00
New-CredentialStore -Shared -Path 'C:\CredentialStore.json'
```
2017-10-16 19:47:19 +02:00
**2.** Now you can manage your credential store items:
2017-09-21 13:32:15 +02:00
```powershell
# This will prompt for credentials and stores it in a private store
New-CredentialStoreItem -RemoteHost 'dc01.myside.local' -Identifier 'AD'
# You can now use it in other scripts like this:
$DCCreds = Get-CredentialStoreItem -RemoteHost 'dc01.myside.local' -Identifier 'AD'
Invoke-Command -ComputerName 'dc01.myside.local' -Credential $DCCreds -ScripBlock {Get-Process}
```
2017-10-16 19:47:19 +02:00
The credential store contains also a simple function to establish a connection with several systems or protocols.
If you have already installed the underlying framework / modules, you can connect these endpoints:
2017-09-21 13:32:15 +02:00
* **CiscoUcs** - Establish a connection to a Cisco UCS fabric interconnect.
* Required Modules: [`Cisco.UCS.Core`, `Cisco.UCSManager` ](https://software.cisco.com/download/release.html?i=!y&mdfid=286305108&softwareid=284574017&release=2.1.1 )
* **FTP** - Establish a connection to a FTP host.
* Required Modules: [`WinSCP` ](https://www.powershellgallery.com/packages/WinSCP )
* **NetAppFAS** - Establish a connection to a NetApp Clustered ONTAP filer.
* Required Modules: [`DataONTAP` ](http://mysupport.netapp.com/tools/info/ECMLP2310788I.html?productID=61926 )
* **VMware** - Establish a connection to a VMware vCenter or ESXi host.
* Required Modules: [`VMware.VimAutomation.Core` ](https://www.powershellgallery.com/packages/VMware.PowerCLI )
2017-10-23 10:53:52 +02:00
* **CisServer** - Establish a connection to the CisServer Service on vCenter Host.
* Required Modules: [`VMware.VimAutomation.Cis.Core` ](https://www.powershellgallery.com/packages/VMware.PowerCLI )
2018-03-09 14:02:51 +01:00
* **ExchangeHTTP** - Establish a remote connection with an Exchange endpoint via http.
* Requires PowerShell remoting
* **ExchangeHTTPS** - Establish a remote connection with an Exchange endpoint via https.
* Requires PowerShell remoting
* **SCP** - Establish a SCP connection.
* Required Modules: [`WinSCP` ](https://www.powershellgallery.com/packages/WinSCP )
2017-09-21 13:32:15 +02:00
Here are some basic examples:
```powershell
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
2017-10-23 10:53:52 +02:00
Connect-To -RemoteHost "vcr.myside.local" -Type CisServer
2019-04-29 16:05:43 +02:00
Connect-To -RemoteHost "exchange1.myside.local" -Type ExchangeHTTP
Connect-To -RemoteHost "exchange1.myside.local" -Type ExchangeHTTPS
Connect-To -RemoteHost "ubuntu.myside.local" -Type SCP
2017-09-21 13:32:15 +02:00
```
2019-01-16 12:55:29 +01:00
2019-04-29 16:05:43 +02:00
:pushpin: Credits
2019-01-16 12:55:29 +01:00
-------
A huge thanks to all the people who helped with their projects and indirect contributions which made this possible!
2019-04-29 16:05:43 +02:00
- This module is inspired by the awesome work of Dave Wyatt ([@dlwyatt](https://github.com/dlwyatt)) with articles like these:
2019-01-16 12:55:29 +01:00
- https://powershell.org/2013/11/24/saving-passwords-and-preventing-other-processes-from-decrypting-them/
- https://powershell.org/2014/02/01/revisited-powershell-and-encryption/
- The awesome people from [LibreSSL ](http://www.libressl.org/ ) which publishes the [portable openssl/libressl binaries ](https://github.com/libressl-portable/portable )!