Bash – IPMItool, bash script

bashipmi

i need to write a bash script that will go in the server to check the ip address of ipmi,

as i read that i can use

ipmitool lan print  

i can write it inside server to show the ip address.

but i need to do this command on my local host and i tried to execute this command:

ipmitool lan print -H *servername* -U admin -P password  

but i found this error

Unable to establish LAN session

what is wrong with my command?

Note: i can access to the server using ssh without problem, but ipmitool doesnt work with ssh in same command line

Best Answer

Firstly, your syntax is incorrect, since the right order should be:

ipmitool [options...] <command>

Moreover, in the parameter -H ipmi_hostname, the hostname here should be the domain name of IPMI interface IP address. It's quite odd to login via IPMI through its own IP to print out its IP(!), so I assume that you want to login via server's hostname. In this case, simply install ipmitool to server, then use SSH to run the command:

ssh hostname ipmitool lan print

If you still want to use ipmitool from another host to execute the IPMI command:

ipmitool -H ipmi_hostname -U ADMIN_USER -P password lan print

Hope this help.