RHEL Subscriptions

To be able to use YUM on an RHEL server you need to register it with the RedHat servers.
NB: You can do this with a Developer account, which is free!
First register the system
# subscription-manager register --auto-attach
that enter your username and password.
or add --username=<username> --password=<password> onto the end of the above command
Next attach a subscription
# subscription-manager list --available | awk '/Pool/ { system ("subscription-manager attach --pool="$3) }'
# subscription-manager attach --auto
Once you are done, you can remove the subscription and server from their systems.
To remove a system from a RHEL subscription you first have to run,
# subscription-manager list --consumed
to get the serial number. Then pass that serial number to the remove command
# subscription-manager remove --serial=XXXXXXX
you can run this command, which does both
# subscription-manager list --consumed | awk '/Serial:/ { system ("subscription-manager remove --serial="$2) }'