Forum Discussion
Hank_Stallings
Nimbostratus
Nov 07, 2014What is the path to a user's home directory from root?
I have a PowerShell script that uploads a pfx file using psftp.exe from PuTTY. When I first sftp'd to the BIG-IP I created a folder named "cert", and the path is /home/USERNAME/cert. I upload the p...
Hank_Stallings
Nimbostratus
Nov 07, 2014I figured it out, all I had to do was change my upload path to the one that worked previously.
POWERSHELL CODE TO UPLOAD CERTIFICATE TO BIG-IP:
$workdir = "E:\PowerShell\SSL\IssuedCerts\PFXs"
$certficate = "www.hanktest24.com"
$Hostname = "bigIP"
$user = "USERNAME"
$pass = "PASSWORD"
$psftpdir = "E:\Program Files (x86)\PuTTY"
$remotedir = "/shared/cert"
$tempContent = $()
$tempContentFile = "$($workdir)\temp_put.txt"
$tempContent += "cd cert "
$tempContent += "nput $workdir"+"\"+"$certficate "
$tempContent += "nexit "
$tempContent += "exit "
$out = Out-File -FilePath $tempContentFile -InputObject $tempContent -Encoding ASCII;
Set-Location -Path $psftpdir
$out = & .\psftp.exe $($Hostname) -l $($user) -pw $($pass) -b $($tempContentFile))
POWERSHELL CODE TO IMPORT THE CERTIFICATE:
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ){
Add-PSSnapIn iControlSnapIn
}
$bigip_name = 'bigIP'
$user = 'USERNAME'
$pass = 'PASSWORD'
$bigip = New-Object -TypeName iControl.Interfaces;
$success = $bigip.initialize($bigip_name, $user, $pass);
$bigip.ManagementPartition.Set_active_partition("Common");
$mgmtmode = New-Object -TypeName iControl.ManagementKeyCertificateManagementModeType
$mgmtmode.value__ = 0
$SSLDir = "E:\PowerShell\SSL\IssuedCerts\PFXs"
$url = "WWW.hanktest24.com"
$pfxfilename = $url + ".pfx"
$pfxfile = "/shared/cert/" + $pfxfilename
$exportPass = "EXPORTPASS"
Set-Location -Path $SSLDir
$bigip.ManagementPartition.Set_active_partition("Common")
$bigip.ManagementKeyCertificate.pkcs12_import_from_file(
($mgmtmode),
($url),
($pfxfile),
($exportPass),
($true)
)
Hope this helps others, because I've been trying to figure this out for months! Appreciate the help of Joe Pruitt!
Thanks,
Hank
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects