9.3. 使用激活码进行主机注册
您可以使用激活码完成以下任务:
- 通过 Red Hat Satellite 在置备过程中注册新主机。Red Hat Satellite 中的 Kickstart 自定义模板包含使用创建主机时定义的激活码注册主机的命令。
- 注册现有的 Red Hat Enterprise Linux 主机。
您可以使用 Satellite Web UI、Hammer CLI 或 Satellite API 中的主机注册功能将主机注册到 Satellite。如需更多信息,请参阅 管理主机 中的 注册主机和设置主机集成。
流程
- 在 Satellite Web UI 中,进入到 Hosts > Register Host。
- 从 Activation Keys 列表中,选择要分配给主机的激活密钥。
- 点 Generate 来创建注册命令。
- 点 files 图标将命令复制到您的剪贴板。
- 使用 SSH 连接到您的主机并运行注册命令。
-
检查
/etc/yum.repos.d/redhat.repo
文件,并确保启用了适当的软件仓库。
CLI 过程
使用 Hammer CLI 生成主机注册命令:
hammer host-registration generate-command \ --activation-keys "My_Activation_Key"
# hammer host-registration generate-command \ --activation-keys "My_Activation_Key"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 如果您的主机不信任 Satellite 服务器的 SSL 证书,您可以通过在注册命令中添加-
insecure
标志来禁用 SSL 验证。hammer host-registration generate-command \ --activation-keys "My_Activation_Key" \ --insecure true
# hammer host-registration generate-command \ --activation-keys "My_Activation_Key" \ --insecure true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 使用 SSH 连接到您的主机并运行注册命令。
-
检查
/etc/yum.repos.d/redhat.repo
文件,并确保启用了适当的软件仓库。
API 流程
使用 Satellite API 生成主机注册命令:
curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"] }}'
# curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"] }}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 如果您的主机不信任 Satellite 服务器的 SSL 证书,您可以通过在注册命令中添加-
insecure
标志来禁用 SSL 验证。curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"], "insecure": true }}'
# curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"], "insecure": true }}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 使用激活码来简化指定环境。如需更多信息,请参阅管理内容中的管理 激活码 。
要输入密码作为命令行参数,请使用
username:password
语法。请记住,这会将密码保存到 shell 历史记录中。或者,您可以使用临时个人访问令牌而不是密码。要在 Satellite Web UI 中生成令牌,请导航到 My Account > Personal Access Tokens。- 使用 SSH 连接到您的主机并运行注册命令。
-
检查
/etc/yum.repos.d/redhat.repo
文件,并确保启用了适当的软件仓库。
多个激活码
在注册内容主机时,您可以使用多个激活码。例如,您可以使用一个激活码来启用特定的存储库,另一个用于分配内容视图和生命周期环境。
设置冲突
如果激活码中有冲突的设置,则最合适的键具有优先权。
- 有冲突的设置:Service Level, Release Version, Environment, Content View, 和 Product Content。
- 没有冲突的设置,主机会获得它们合并: Host Collections。
- 影响密钥本身和主机配置行为的设置: 内容主机限制。