Check subscription manager status
Bash
sudo -s # If in Docker not needed
if [ "$(subscription-manager status| grep "Overall Status")" != "Overall Status: Unknown" ]; then
clear
echo "Properly Registered"
else
echo -e "Needs Registered\n\nPlease get with your server team to register this server"
$SHELL
fiRegister If Not Registered
Bash
sudo -s # If in Docker not needed
if [ "$(subscription-manager status| grep "Overall Status")" != "Overall Status: Unknown" ]; then
echo "Properly Registered"
else
echo -e "\033[32mRed Hat Registration - Start\033[0m"
if [ -z ${1+x} ]; then
echo -e "\033[01m\e[4mType your username for RedHat.com, followed by [ENTER]:\e[0m\033[0m"
read rhUser
else
#echo "rhUser is set to '$1'"
declare rhUser=$1
fi
if [ -z ${2+x} ]; then
echo -e "\033[01m\e[4mType your password for RedHat.com, followed by [ENTER]:\e[0m\033[0m"
read -s rhPass
else
#echo "rhPass is set to '$2'"
declare rhPass=$2
fi
echo -e "\033[32mSet Server Hostname - Start\033[0m"
if [ -z ${3+x} ]; then
echo -e "\033[01m\e[4mType your desired hostname for the server, followed by [ENTER]:\e[0m\033[0m"
read hostname
hostnamectl set-hostname $hostname
else
declare hostname=$3
hostnamectl set-hostname $hostname
fi
echo -e "\033[32mSet Server Hostname - Stop\033[0m"
# Register Red Hat Server - Start
subscription-manager register --username $rhUser --password $rhPass
subscription-manager refresh
history -c
subscription-manager identity
# Register Red Hat Server - Stop
echo -e "\033[32mRed Hat Registration - Stop\033[0m"
fiIf you have restored a previous snapshot or somehow lost the subscription connection, you should unregister and then go through the above process to “re-register”.
Bash
sudo subscription-manager unregisterOriginally Posted on February 21, 2017
Last Updated on November 20, 2025
Last Updated on November 20, 2025
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.