Last active
August 18, 2019 21:29
-
-
Save adambarthelson/a0382beaf1ccb48e4c5dcf09f089e0e3 to your computer and use it in GitHub Desktop.
An Expect script to automate creating a new user for CloudHSM and activating the HSM initially by updating the admin password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set adminpassword [lindex $argv 0] | |
set newusername [lindex $argv 1] | |
set newuserpwd [lindex $argv 2] | |
set timeout 5 | |
spawn /opt/cloudhsm/bin/cloudhsm_mgmt_util /opt/cloudhsm/etc/cloudhsm_mgmt_util.cfg | |
expect -re "aws-cloudhsm*" { | |
send "enable_e2e\r" | |
send "loginHSM CO admin $adminpassword\r" | |
expect -re "success*" | |
send "\r" | |
send "createUser CU $newusername $newuserpwd\r" | |
expect -re "continue*" | |
send "y\r" | |
expect -re "success" | |
send "\r" | |
send "listUsers\r" | |
send "\r" | |
send "quit\r" | |
} | |
exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set adminpassword [lindex $argv 0] | |
set timeout 5 | |
spawn /opt/cloudhsm/bin/cloudhsm_mgmt_util /opt/cloudhsm/etc/cloudhsm_mgmt_util.cfg | |
expect -re "aws-cloudhsm*" { | |
send "enable_e2e\r" | |
send "loginHSM PRECO admin password\r" | |
expect -re "success*" | |
send "\r" | |
send "changePswd PRECO admin $adminpassword\r" | |
expect -re "continue*" | |
send "y\r" | |
expect -re "CAUTION*" | |
send "\r" | |
send "logoutHSM\r" | |
send "\r" | |
expect -re "" | |
} | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment