How to Use These Scripts

  1. Register SSH Server

The first script registers an SSH server with the MiniDiscovery service:

bash

chmod +x register_ssh_server.sh ./register_ssh_server.sh -t YOUR_API_TOKEN

Options:

-t, --token TOKEN - API token for authentication (required)
-u, --url URL - Base URL of the API (default: http://localhost:8500)
-n, --name NAME - Server name (default: ssh-server)
-a, --address ADDRESS - Server address (default: 127.0.0.1)
-p, --port PORT - SSH port (default: 22)
--tags TAGS - Comma-separated tags (default: ssh,secure)

Example with custom values:

bash

./register_ssh_server.sh -t YOUR_API_TOKEN -n prod-ssh -a 192.168.1.50 -p 2222 --tags "ssh,secure,production"

  1. List Services

The second script lists all services or instances of a specific service:

bash

chmod +x list_services.sh ./list_services.sh -t YOUR_API_TOKEN

Options:

-t, --token TOKEN - API token for authentication (required)
-u, --url URL - Base URL of the API
-s, --service NAME - List instances of a specific service
-p, --passing - Only show instances passing health checks

Example to list specific service:

bash

./list_services.sh -t YOUR_API_TOKEN -s ssh-server

  1. Deregister Service

The third script removes a service from the discovery service:

bash

chmod +x deregister_service.sh ./deregister_service.sh -t YOUR_API_TOKEN -i SERVICE_ID

Options:

-t, --token TOKEN - API token for authentication (required)
-u, --url URL - Base URL of the API
-i, --id SERVICE_ID - Service ID to deregister
--last - Deregister the last registered service (uses stored ID)

Example using the last registered service:

bash

./deregister_service.sh -t YOUR_API_TOKEN --last

Note: The registration script saves the service ID to a file called .last_registered_service_id, which the deregistration script can use with the --last option.