Skip to content

Instantly share code, notes, and snippets.

@Alex4386
Last active March 15, 2024 08:49
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Alex4386/344f2235ee54604a8fe1704d56c6c14e to your computer and use it in GitHub Desktop.
Save Alex4386/344f2235ee54604a8fe1704d56c6c14e to your computer and use it in GitHub Desktop.
iDRAC 6 SSL Certificate Deploy Tool - with certbot
@echo off
echo Dell iDRAC 6 SSL Key upload system
echo.
echo ===[credentials]===
set default_hostname=your.idrac.address
rem Host Section
set /p host="Host (Default. %default_hostname%): "
IF NOT DEFINED host (
echo Host was not provided, using %default_hostname%
set host=%default_hostname%
)
rem Username Section
set /p idrac_username=Username (Default. root):
IF NOT DEFINED idrac_username (
echo Username was not provided, using root
set idrac_username=root
)
rem Password Section
set /p password=Password:
IF NOT DEFINED password (
echo Password was not provided, Terminating!
echo.
pause
goto end
)
echo.
echo ===[credentials check]===
echo Host: %host%
echo Username: %idrac_username%
echo Password: %password%
echo.
echo Is this correct? Press any key to continue.
pause>nul
echo.
echo ===[validating]===
IF NOT EXIST certs (
echo certs directory is not existent!
echo please extract letsencrypt certificate and unzip it to certs directory using
echo letsencrypt certificate loader
echo.
pause
goto end
)
echo validation complete!
echo.
echo ===[get remote config]===
echo getting remote config
racadm -r %host% -u %idrac_username% -p %password% -v 4 getconfig -g cfgRacSecurity
echo.
echo if you are getting inadequate size (ex. 1024), please change it with command
echo.
echo racadm -r %host% -u %idrac_username% -p %password% config -g cfgRacSecurity -o cfgRacSecCsrKeySize 2048
echo.
echo else, continue.
pause>nul
echo.
echo ===[uploading]===
echo uploading private key...
racadm -r %host% -u %idrac_username% -p %password% -v 4 sslkeyupload -t 1 -f .\certs\privkey.pem
echo private key uploaded.
echo.
echo uploading certificate...
racadm -r %host% -u %idrac_username% -p %password% -v 4 sslcertupload -t 1 -f .\certs\cert.pem
echo certificate uploaded.
echo.
echo ===[done]===
echo done.
echo.
pause
:end
#!/bin/bash
LETSENCRYPT="/etc/letsencrypt/live"
CERT_HOSTNAME="the_hostname"
test -z "$1" || CERT_HOSTNAME="$1"
CERTDIR="$LETSENCRYPT/$CERT_HOSTNAME"
echo "LetsEncrypt Certificate Loader"
echo
echo "Retrieving certificate for $CERT_HOSTNAME"
echo
echo "===[ INITIALIZATION ]==="
echo "Setting up certificate directory..."
test -d "certs" && rm -rf certs
mkdir "certs"
test -d "backup" || mkdir "backup"
echo
echo "===[ VALIDATION ]==="
sudo test -d $CERTDIR || echo "[Error] certificate for $CERT_HOSTNAME doesn't exist!"
sudo test -d $CERTDIR || exit 1
echo "Certificate Hostname: $CERT_HOSTNAME, OK!"
echo
echo "===[ PROCESS ]==="
echo "Copying files..."
sudo cp -f $CERTDIR/cert.pem ./certs/
sudo cp -f $CERTDIR/chain.pem ./certs/
sudo cp -f $CERTDIR/fullchain.pem ./certs/
sudo cp -f $CERTDIR/privkey.pem ./certs/
echo "Setting owner to $USER"
sudo chown -R $USER ./certs/
echo "Changing it to read-only"
chmod -R 0700 ./certs/
echo "Packing up!"
zip -r certs.zip certs/ > /dev/null
echo
echo "===[ BACKUP ]==="
NOW=$(date +"%Y%m%d%H%M")
BACKUP_DIR="backup/certs_${CERT_HOSTNAME}_$NOW"
echo "Backing up to ${BACKUP_DIR}"
mv certs $BACKUP_DIR
echo
echo "===[ DONE ]==="
echo "Done!"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment