The host module provides commands to manage SSH host entries in your ~/.ssh/config file. Each command is described below.
This command allows you to create a new host entry in your SSH config.
cosmos host create --host <host> --hostname <hostname> --user <username> [--port <port>] [--identity-file <path>]--host, -h: Host alias (required)--hostname, -hn: Hostname (IP or domain) (required)--user, -u: Username (required)--port, -p: Port (default: 22)--identity-file, -i: Path to private key (default:~/.ssh/id_rsa)
Behavior: If any required flag is missing, you will be prompted to provide it interactively.
Create a host entry for myserver:
cosmos host create --host myserver --hostname 192.168.1.10 --user ubuntuThis command lists all hosts in your SSH config.
cosmos host listDisplays a table with the following columns:
- Host
- Hostname
- User
- Port
- IdentityFile
List all hosts:
cosmos host listThis command shows details of a specific host in your SSH config.
cosmos host show <host><host>: The host alias to show details for.
Displays all details for the specified host.
Show details for myserver:
cosmos host show myserverThis command removes a host entry from your SSH config.
cosmos host remove <host><name>: Host alias to remove.
Behavior: If the alias is not provided, you will be prompted to enter it.
Remove the host entry for myserver:
cosmos host remove myserverThis command updates an existing host entry in your SSH config.
cosmos host update <host> [--user <username>] [--port <port>] [--host <alias>] [--hostname <hostname>] [--identity-file <path>]<name>: Host alias to update.
--host, -h: Host alias--hostname, -h: Hostname (IP or domain)--user, -u: Username--port, -p: Port--identity-file, -i: Path to private key
Behavior: If the alias is not provided, you will be prompted to enter it. Only the provided fields will be updated.
Update the user and port for myserver:
cosmos host update myserver --user admin --port 2222This command allows you to set a metadata key-value pair for a specified host.
It is used maily by other modules to register capabilities or features of the host, such as Docker support.
cosmos host set <host> <key> <value><host>: The hostname, IP, or alias of the target host.<key>: The metadata key to set.<value>: The value to set for the key. You can prefix the value withbool:ornumber:to cast the value (e.g.,bool:true,number:42).
Set a string metadata value:
cosmos host set myserver location "datacenter-1"Set a boolean metadata value:
cosmos host set myserver enabled bool:trueSet a numeric metadata value:
cosmos host set myserver max_connections number:100This command allows you to remove a metadata key from a specified host.
cosmos host unset <host> <key><host>: The hostname, IP, or alias of the target host.<key>: The metadata key to remove.
Remove a metadata key:
cosmos host unset myserver location