Here is a HP powershell cmdlet for ilo devices
This is what the man page for the cmd says
===
PS C:\> Import-HPiLOSSHKey -Server $Server |
Username is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Username for these servers? (Y/N) : Y
Please enter Username : alansmith
Password is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Password for these servers? (Y/N) : Y
Please enter Password : ************
SSH key not provided...
Please provide SSH key: -----BEGIN SSH KEY-----
ssh-dss
SampleKeyAAALftnNE12JR8T8XQqyzqc1tt6FLFRXLRM5PJpOf/IG4hN45
+x+JbaqkhH+aKqFjlfO1NjszHrFN26H1AhWOjY2bEwj2wlJzBMAhXwnPQelQsCnJDf+
zCzbDn+5Va86+qWxm0lsDEChvZPM6wpjkXvHwuInjxTzOGQTq++vmYlo1/AAAAFQC1M
AAAIAQ46i6FBzJAYXziF/qmWMt4y6SlylOQDAsxPKk7rpxegv8RlTeon/aeL7ojb9GQ
2xnEN5gobaNZxKz2d4/jwg3+qgTDT6V1G+b7+nEI/XHIc717/7oqgiOv4VE3WxN+HE9
JWsv2jwUpAzRGqJOoojRG/CCru0K+jgTOf/di1o0sw== ASmith
-----END SSH KEY-----
$Server is passed as parameter to Import-HPiLOSSHKey. It can be a string array having iLO IP addresses in string
format or it can be an array of PowerShell objects having iLO details including IP address. Because the username
and passwords are not provided for the iLOs, you are asked to input these values.
==
so i tried this
PS C:\> Import-HPiLOSSHKey -DisableCertificateAuthentication -Server "xx" |
Username is not provided for the following iLO Server(s):
xx
.
Enter Username.: admin
Password is not provided for the following iLO Server(s):
xx
.
Enter Password.: **************
SSHKey is not provided for the following iLO Server(s):
xx
.
Enter SSHKey.: -----BEGIN SSH KEY-----
IP HOSTNAME STATUS_TYPE STATUS_MESSAGE
-- -------- ----------- --------------
x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ERROR SSH key was not found.
PS C:\>
==
also tried other combinations
tried
Enter SSHKey.: -----BEGIN SSH KEY-----ssh-rsa xx2fLQ== xx-----END SSH KEY-
even $sshkey tried as well,
==
All gave same err
SSH key was not found.
In google i did not find much not on HP site as well & their PDF as well
http://h20565.www2.hpe.com/hpsc/doc/public/display?docId=c03958206
Can anyone suggest what is the issue here , thanks
What does this say?
Get-command -Syntax -Name Import-HPiLOSSHKey
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD
PS C:\> Get-command -Syntax -Name Import-HPiLOSSHKey
Import-HPiLOSSHKey [-Server <Object>] [-Username <Object>] [-Password <Object>] [-Credential <pscredential[]>]
[-SSHKey <Object>] [-DisableCertificateAuthentication] [-OutputType <string>] [-Force] [<CommonParameters>]
PS C:\>
We need to find out what kind of Object is expected on the SSHKey parameter.
Let's hope there is some decent Help.
Do a
Get-Help -Name Import-HPiLOSSHKey -Full
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PS C:\> Get-Help -Name Import-HPiLOSSHKey -Full
NAME
Import-HPiLOSSHKey
SYNOPSIS
Imports an SSH Key and associated username into iLO.
SYNTAX
Import-HPiLOSSHKey -Server <String, PSObject, Array List, list of String and/or PSObject> [-Credential
<PSCredential[], PSObject, list of PSCredential and/or PSObject>] [-Username <String, PSObject, Array List, list
of String and/or PSObject>] [-Password <String, PSObject, Array List, list of String and/or PSObject>] -SSHKey
<String, PSObject, Array List, list of String and/or PSObject> [-OutputType <String>] [-Force <SwitchParameter>]
[-DisableCertificateAuthentication <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Import-HPiLOSSHKey cmdlet imports a SSH Key and associated username into iLO.
A list of servers (with or without port number) and corresponding username/password or credential values must be
provided as parameters.
PARAMETERS
-Server <String, PSObject, Array List, list of String and/or PSObject>
Specifies the list of iLO with details in PowerShell object format or in a string format. The PowerShell
object may contain fields such as IP Address, Hostname, or FQDN. The object may also contain the userid and
password required to access the iLO. A range of iLO IPs can also be provided in the same string.
IPv6 values for IP address can be used on iLO 3 firmware version 1.70 and later and also on iLO 4 firmware
version 1.40 and later.
The following are examples of Server parameters:
Example 1.
$serverSet1 = "81.2.84.150"
Example 2.
$serverSet2 = New-Object PSObject |
Add-Member NoteProperty IP 81.2.84.150 -PassThru |
Add-Member NoteProperty SPN "ProLiant DL360p Gen8" -PassThru |
Add-Member NoteProperty FWRI 1.10 -PassThru |
Add-Member NoteProperty PN "Integrated Lights-Out 4 (iLO 4)" -PassThru |
Add-Member NoteProperty HOSTNAME ilomxq12345cs.company.net -PassThru |
Add-Member NoteProperty MACADDRESS 00:A0:C9:14:C8:29 -PassThru
Example 3.
$serverObj1 = New-Object PSObject |
Add-Member NoteProperty IP 81.2.84.150 -PassThru |
Add-Member NoteProperty SPN "ProLiant DL360p Gen8" -PassThru |
Add-Member NoteProperty FWRI 1.10 -PassThru |
Add-Member NoteProperty PN "Integrated Lights-Out 4 (iLO 4)" -PassThru |
Add-Member NoteProperty HOSTNAME ilomxq12345cs.company.net -PassThru |
Add-Member NoteProperty MACADDRESS 00:A0:C9:14:C8:29 -PassThru
$serverSet1 = @("81.2.84.150", $serverObj1,"81.2.88.158,161", "81.2.88.170-175", "2607:f0d0:1002:51::4")
Example 4.
$serverSet4 = "81.2.84.150:8888"
Example 5.
$serverSet5 = "[2607:f0d0:1002:51::4]:8888"
Example 6.
$serverSet6 = New-Object -TypeName System.Collections.ArrayList
$serverSet6.Add("81.2.84.150")
$serverSet6.Add("81.2.88.158,161")
$serverSet6.Add("81.2.88.170-175")
Required? true
Position? named
Default value None
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-Credential <PSCredential[], PSObject, list of PSCredential and/or PSObject>
Credential object Array based on username and password to log onto the iLO. Credential should not be used
along with Username/Password.
Required? false
Position? named
Default value None
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Username <String, PSObject, Array List, list of String and/or PSObject>
Specifies the single username for all the iLOs or a list of usernames for each iLO in the input iLO list. It
can be a single string or it can be a collection of usernames in the form of a string array.
Required? false
Position? named
Default value None
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Password <String, PSObject, Array List, list of String and/or PSObject>
Specifies the single password for all the iLOs or a list of passwords for each iLO in the input iLO list. It
can be a single string or it can be a collection of passwords in the form of a string array.
Required? false
Position? named
Default value None
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-SSHKey <String, PSObject, Array List, list of String and/or PSObject>
After generating an SSH key using ssh-keygen, puttygen.exe, or another SSH key generating utility to produce a
1024 bit DSA key, and creating the key.pub file, perform the following:
1. Locate the key.pub file and insert the contents between
-----BEGIN SSH KEY-----
and
-----END SSH KEY-----
The file begins with the text: ssh-dss.
2. At the end of the key, append a space and the name of a valid iLO username as displayed on the Modify User
page.
For example:
xxx_some text_xxx ASmith.
The username is case-sensitive and must match the case of the iLO username to associate the SSH key with the
correct user.
Example of SSH Key with the user:
-----BEGIN SSH KEY-----
ssh-dss
ASampleKeyAAALftnNE12JR8T8XQqyzqc1tt6FLFRXLRM5PJpOf/IG4hN45
+x+JbaqkhH+aKqFjlfO1NjszHrFN26H1AhWOjY2bEwj2wlJzBMAhXwnPQelQsCnJDf+
zCzbDn+5Va86+qWxm0lsDEChvZPM6wpjkXvHwuInjxTzOGQTq++vmYlo1/AAAAFQC1M
FaZjE995QhX9H1DaDzpsVTXvwAAAIA6ec/hAkas2N762jtlHvSuvZaQRzu49DOtjXVI
pNdJAhTC8O2505PzkGLf5qhrbDnusclCvoH7DuxyHjeOUVxbC5wFQBcGF4VnpYZ8nGQ
Gt9TQ0iUV+NRwn4CR5ESoi63zTJIvKIYZDT2ISeXhF2iU6txjZzdeEm7vQz3slaY3dg
AAAIAQ46i6FBzJAYXziF/qmWMt4y6SlylOQDAsxPKk7rpxegv8RlTeon/aeL7ojb9GQ
2xnEN5gobaNZxKz2d4/jwg3+qgTDT6V1G+b7+nEI/XHIc717/7oqgiOv4VE3WxN+HE9
JWsv2jwUpAzRGqJOoojRG/CCru0K+jgTOf/di1o0sw== ASmith
-----END SSH KEY-----
Required? true
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-OutputType <String>
Specifies the type of required output. Possible value can be ExternalCommand, XML, RIBCL, or PSObject. Default
value is PSObject.
The value ExternalCommand for the parameter OutputType creates RIBCL command with other details that are
passed to the OA cmdlet Invoke-HPOAiLOCommand from HPOACmdlets. See the user guide for an example.
Required? false
Position? named
Default value PSObject
Accept pipeline input? false
Accept wildcard characters? false
-Force <SwitchParameter>
Suppresses the prompt that asks for a required parameter. Without this parameter, Import-HPiLOSSHKey requires
you to provide the values of all required parameters that are missing, interactively. Setting this will cause
an error for any missing required parameters.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DisableCertificateAuthentication <SwitchParameter>
If this switch parameter is present then server certificate authentication is disabled for the execution of
this cmdlet. If not present it will execute according to the global certificate authentication setting. The
default is to authenticate server certificates. See Enable-HPiLOCertificateAuthentication and
Disable-HPiLOCertificateAuthentication to set the per PowerShell session default.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
PSObject OR array of PSObject OR String OR array of String
You can pipe one IP address or a list of IP addresses as Strings, or one PSObject or list of PSObjects having
the iLO details such as IP Address, Hostname, Username and Password to access the iLO.
OUTPUTS
When the cmdlet does not execute correctly, output with the error message is produced. Otherwise, this cmdlet
does not generate any output. Use Get-Member to get details of fields in returned objects.
NOTES
Some forms of command line parameters must be enclosed in quotes for correct interpretation by the system. For
example, a string parameter of 1234 is interpreted as a number instead of a string without quotes. An IP
address set of 10.10.10.11,33 would also be misinterpreted.
Use either "1234" or "10.10.10.11,33" to get the expected results.
-------------------------- EXAMPLE 1 --------------------------
PS C:\> Import-HPiLOSSHKey
Please enter Server IP or Hostname: 1.4.217.131,187
Do you want to add details for another server?(Y/N) : y
Please enter Server IP or Hostname: 1.4.209.53
Do you want to add details for another server?(Y/N) : n
Username is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Username for these servers? (Y/N) : N
Enter Username for 1.4.217.131: administrator
Enter Username for 1.4.217.187: alansmith
Enter Username for 1.4.209.53: timhorton
Password is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Password for these servers? (Y/N) : N
Enter Password for 1.4.217.131: ************
Enter Password for 1.4.217.187: ************
Enter Password for 1.4.209.53: ************
SSH key not provided...
Please provide SSH key: -----BEGIN SSH KEY-----
ssh-dss
SampleKeyAAALftnNE12JR8T8XQqyzqc1tt6FLFRXLRM5PJpOf/IG4hN45
+x+JbaqkhH+aKqFjlfO1NjszHrFN26H1AhWOjY2bEwj2wlJzBMAhXwnPQelQsCnJDf+
zCzbDn+5Va86+qWxm0lsDEChvZPM6wpjkXvHwuInjxTzOGQTq++vmYlo1/AAAAFQC1M
AAAIAQ46i6FBzJAYXziF/qmWMt4y6SlylOQDAsxPKk7rpxegv8RlTeon/aeL7ojb9GQ
2xnEN5gobaNZxKz2d4/jwg3+qgTDT6V1G+b7+nEI/XHIc717/7oqgiOv4VE3WxN+HE9
JWsv2jwUpAzRGqJOoojRG/CCru0K+jgTOf/di1o0sw== ASmith
-----END SSH KEY-----
This command shows a basic usage scenario where only the cmdlet name is entered. You are asked if the same
credentials are to be used for multiple input servers or if separate credentials have to be collected for each
server. Then you are asked if the same values for parameters are to be passed to the cmdlets or separate
parameters are going to be used for each server. A list of iLO details is passed to the cmdlet in the form of
PowerShell object or list of PowerShell objects or list of IP addresses of the iLO.
-------------------------- EXAMPLE 2 --------------------------
PS C:\> Import-HPiLOSSHKey -Server $Server
Username is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Username for these servers? (Y/N) : Y
Please enter Username : alansmith
Password is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Password for these servers? (Y/N) : Y
Please enter Password : ************
SSH key not provided...
Please provide SSH key: -----BEGIN SSH KEY-----
ssh-dss
SampleKeyAAALftnNE12JR8T8XQqyzqc1tt6FLFRXLRM5PJpOf/IG4hN45
+x+JbaqkhH+aKqFjlfO1NjszHrFN26H1AhWOjY2bEwj2wlJzBMAhXwnPQelQsCnJDf+
zCzbDn+5Va86+qWxm0lsDEChvZPM6wpjkXvHwuInjxTzOGQTq++vmYlo1/AAAAFQC1M
AAAIAQ46i6FBzJAYXziF/qmWMt4y6SlylOQDAsxPKk7rpxegv8RlTeon/aeL7ojb9GQ
2xnEN5gobaNZxKz2d4/jwg3+qgTDT6V1G+b7+nEI/XHIc717/7oqgiOv4VE3WxN+HE9
JWsv2jwUpAzRGqJOoojRG/CCru0K+jgTOf/di1o0sw== ASmith
-----END SSH KEY-----
$Server is passed as parameter to Import-HPiLOSSHKey. It can be a string array having iLO IP addresses in string
format or it can be an array of PowerShell objects having iLO details including IP address. Because the username
and passwords are not provided for the iLOs, you are asked to input these values.
-------------------------- EXAMPLE 3 --------------------------
PS C:\> Import-HPiLOSSHKey -Server $Server -Username $Username -Password $Password -SSHKey $SSHKey
This command shows that the list of iLO server addresses is passed as a parameter along with usernames and
passwords.
RELATED LINKS
http://www.hpe.com/servers/powershell
PS C:\>
It seems you have to append the user (ASmith in the example) to the content of the public key.
From your screenshots it looks like you used ASmith, is that your iLO username?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD
i used , id_rsa.pub file from my linux box as my public key
when ssh keys are created with ssh-keygen command in linux it adds username to public key created , so my keys has root@hostname at the end of the key
Anyways that is ( ASmith) not the problem as they clearly says add contents of .pub file in the begin & end lines.
In point 2 they seem to state "2. At the end of the key, append a space and the name of a valid iLO username as displayed on the Modify User page."
Is root@hostname a valid iLO username?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD
good catch
the username is admin, i appened that at the key of key
but no luck
$SSHKey = "-----BEGIN SSH KEY-----
ssh-rsa ....E6AD8F6STpoYXVOx... admin
-----END SSH KEY-----"
Import-HPiLOSSHKey -DisableCertificateAuthentication -Server "ixx" -Username "admin" -Password "xx" -SSHKey $SSHKey
other problem is as soon as i type the key 1st line & press enter it gives err
#############################################################
PS C:\> Import-HPiLOSSHKey -Server $Server |
Username is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Username for these servers? (Y/N) : Y
Please enter Username : alansmith
Password is not provided for the following iLO Server(s):
1.4.217.131
1.4.217.187
1.4.209.53
Use same Password for these servers? (Y/N) : Y
Please enter Password : ************
SSH key not provided...
Please provide SSH key: -----BEGIN SSH KEY-----
ssh-dss
SampleKeyAAALftnNE12JR8T8XQqyzqc1tt6FLFRXLRM5PJpOf/IG4hN45
+x+JbaqkhH+aKqFjlfO1NjszHrFN26H1AhWOjY2bEwj2wlJzBMAhXwnPQelQsCnJDf+
zCzbDn+5Va86+qWxm0lsDEChvZPM6wpjkXvHwuInjxTzOGQTq++vmYlo1/AAAAFQC1M
AAAIAQ46i6FBzJAYXziF/qmWMt4y6SlylOQDAsxPKk7rpxegv8RlTeon/aeL7ojb9GQ
2xnEN5gobaNZxKz2d4/jwg3+qgTDT6V1G+b7+nEI/XHIc717/7oqgiOv4VE3WxN+HE9
JWsv2jwUpAzRGqJOoojRG/CCru0K+jgTOf/di1o0sw== ASmith
-----END SSH KEY-----
$Server is passed as parameter to Import-HPiLOSSHKey. It can be a string array having iLO IP addresses in string
format or it can be an array of PowerShell objects having iLO details including IP address. Because the username
and passwords are not provided for the iLOs, you are asked to input these values.
#############################################################
ie when i press enter after below line it come out & give err
Please provide SSH key: -----BEGIN SSH KEY-----
Hence i am trying to use $sshkey where i use a format in the way they want
That sounds as if you are trying to do this from the command prompt.
Is that correct?
Why not place it in a .ps1 file, and execute that one from the command prompt?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes as the example had it run on cmd prompt so i gave it a try
Import-HPiLOSSHKey -DisableCertificateAuthentication -Server "xx" -Username "admin" -Password "xx"
i kept above in ps1 file but same result
also tried
$sshkey in ps1 one but same issue
It looks as if you didn't provide the key on the Import-HPiLOSSHKey cmdlet.
Could you perhaps attach the .ps1 file you are using, and a screenshot of the result when you run the .ps1 file.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ps1 file is
$SSHKey = "-----BEGIN SSH KEY-----
ssh-dss xxx= root@xxx admin
-----END SSH KEY-----"
Import-HPiLOSSHKey -DisableCertificateAuthentication -Server "xx" -Username "admin" -Password "xxx" -SSHKey $SSHKey
Seems that we don't see the complete error message.
Can you try running it like this.
Note the pipeline symbol at the end of line!
$SSHKey = "-----BEGIN SSH KEY-----
ssh-dss xxx= root@xxx admin
-----END SSH KEY-----"
Import-HPiLOSSHKey -DisableCertificateAuthentication -Server "xx" -Username "admin" -Password "xxx" -SSHKey $SSHKey |
Format-List
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Well no that has only same col. below is o/p when i did , |Format-List
IP : xxx
HOSTNAME : xx
STATUS_TYPE : ERROR
STATUS_MESSAGE : SSH key was not found.