Alpacon CLI is a command-line tool for managing Alpacon — a platform for secure remote access, server automation, and certificate management. This CLI lets you interact with your Alpacon workspace directly from the terminal.
Alpacon consists of the following components:
- Alpacon Server — The platform for secure remote access and server automation. Sign up for a workspace at alpacon.io to get started.
- Alpamon — An open-source agent installed on managed servers to enable remote access and monitoring.
- Alpacon CLI (this repository) — A command-line client for interacting with your Alpacon workspace.
Note
This README is intended as a development and contribution guide. For production usage and deployment, please refer to the official documentation.
Download the latest Alpacon CLI directly from our releases page or install it using package managers.
Important
Building from source is intended for development purposes only. For production use, please install via package managers or download pre-built binaries from the releases page. See the official documentation for more details.
For every release and Release Candidate (RC), we push a corresponding container image to our Docker Hub repository at alpacax/alpacon-cli. For example:
docker run --rm -it alpacax/alpacon-cli versionMake sure you have Go installed:
git clone https://github.com/alpacax/alpacon-cli.git
cd alpacon-cli
go build
sudo mv alpacon-cli /usr/local/bin/alpaconbrew tap alpacax/alpacon
brew install alpacon-cliNote for existing users: If you encounter any issues with
brew upgrade, please run:brew uninstall alpacon-cli brew untap alpacax/cli brew tap alpacax/alpacon brew install alpacon-cli
VERSION=<latest-version> # Replace with the actual version
wget https://github.com/alpacax/alpacon-cli/releases/download/${VERSION}/alpacon-${VERSION}-darwin-arm64.tar.gz
tar -xvf alpacon-${VERSION}-darwin-arm64.tar.gz
chmod +x alpacon
sudo mv alpacon /usr/local/bincurl -s https://packagecloud.io/install/repositories/alpacax/alpacon/script.deb.sh?any=true | sudo bash
sudo apt-get install alpaconcurl -s https://packagecloud.io/install/repositories/alpacax/alpacon/script.rpm.sh?any=true | sudo bash
sudo yum install alpaconVERSION=<latest-version> # Replace with the actual version
wget https://github.com/alpacax/alpacon-cli/releases/download/${VERSION}/alpacon-${VERSION}-linux-amd64.tar.gz
tar -xvf alpacon-${VERSION}-linux-amd64.tar.gz
chmod +x alpacon
sudo mv alpacon /usr/local/binDownload the latest .zip archive for Windows from GitHub Releases and add the binary to your PATH.
To access and utilize all features of Alpacon CLI, first authenticate with your Alpacon workspace:
$ alpacon login
# Cloud login (portal URL or API URL)
$ alpacon login https://alpacon.io/myworkspace
$ alpacon login myworkspace.us1.alpacon.io
# Self-hosted
$ alpacon login alpacon.example.com
# Log in via API token
$ alpacon login myworkspace.us1.alpacon.io -t [TOKEN_KEY]
# Legacy username/password
$ alpacon login [WORKSPACE_URL] -u [USERNAME] -p [PASSWORD]
# Skip TLS certificate verification
$ alpacon login [WORKSPACE_URL] --insecure
# Logout
$ alpacon logoutA successful login generates a config.json file in ~/.alpacon, which includes the workspace url, API token, and token expiration time (approximately 1 week).
This file is crucial for executing commands, and you will need to log in again once the token expires.
Upon re-login, the Alpacon CLI will automatically reuse the workspace URL from config.json, unless you provide a workspace URL as an argument.
Explore Alpacon CLI's capabilities with the -h or help command.
$ alpacon -h
Use this tool to interact with the alpacon service.
Usage:
alpacon [flags]
alpacon [command]
Available Commands:
agent Commands to manage server's agent
authority Commands to manage and interact with certificate authorities
cert Manage and interact with SSL/TLS certificates
completion Generate the autocompletion script for the specified shell
cp Copy files between local and remote locations
csr Generate and manage Certificate Signing Request (CSR) operations
event Retrieve and display recent Alpacon events.
exec Execute a command on a remote server
group Manage Group resources
help Help about any command
log Retrieve and display server logs
login Log in to Alpacon
logout Log out of Alpacon
note Manage and view server notes
package Commands to manage and interact with packages
server Commands to manage and interact with servers
token Commands to manage api tokens
tunnel Create a TCP tunnel to a remote server
user Manage User resources
version Displays the current CLI version.
websh Open a websh terminal or execute a command on a serverManage and interact with servers efficiently using Alpacon CLI:
# List all servers.
$ alpacon server ls / list / all
# Get detailed information about a specific server.
$ alpacon server describe [SERVER NAME]
# Interactive server creation process.
$ alpacon server create
# Delete server
$ alpacon server delete [SERVER NAME]
$ alpacon server rm [SERVER NAME]
Server Name:
Platform(debian, rhel):
Groups:
[1] alpacon
[2] auditors
[3] designers
[4] developers
[5] managers
[6] operators
Select groups that are authorized to access this server. (e.g., 1,2):Access a server's websh terminal:
# Open a websh terminal for the specified server.
$ alpacon websh [SERVER NAME]
# Open a websh terminal as the root user.
$ alpacon websh -r [SERVER NAME]
# Open a websh terminal for the specified server using a specified username and groupname.
$ alpacon websh -u [USER NAME] -g [GROUP NAME] [SERVER NAME]Execute a command directly on a server and retrieve the output:
$ alpacon websh [SERVER NAME] [COMMAND]
$ alpacon websh -u [USER NAME] -g [GROUP NAME] [SERVER NAME] [COMMAND]
$ alpacon websh --username=[USER NAME] --groupname=[GROUP NAME] [SERVER NAME] [COMMAND]
$ alpacon websh --env="KEY1=VALUE1" --env="KEY2=VALUE2" [SERVER NAME] [COMMAND]
# Use the current shell's value for the environment variable 'KEY'.
$ alpacon websh --env="KEY" [SERVER NAME] [COMMAND]- Note: All flags must be placed before the
[SERVER NAME].
Execute a command on a remote server using SSH-like user@host syntax:
# Execute a command on a server
$ alpacon exec [SERVER NAME] [COMMAND]
# Use SSH-style user@host syntax
$ alpacon exec root@prod-docker docker ps
$ alpacon exec admin@web-server ls -la /var/log
# Specify username and groupname via flags
$ alpacon exec -u root prod-docker systemctl status nginx
$ alpacon exec -g docker user@server docker imagesCreate a TCP tunnel that forwards local port traffic to a remote server's port:
# Forward local port 9000 to remote server's port 8082
$ alpacon tunnel [SERVER NAME] -l 9000 -r 8082
# Forward local port 2222 to remote server's SSH port (22)
$ alpacon tunnel [SERVER NAME] -l 2222 -r 22
# Specify username and groupname for the tunnel
$ alpacon tunnel [SERVER NAME] -l [LOCAL PORT] -r [REMOTE PORT] -u [USER NAME] -g [GROUP NAME]
# Enable verbose connection logs
$ alpacon tunnel [SERVER NAME] -l 9000 -r 8082 -vYou can share the current terminal to others via a temporary link:
# Open a websh terminal and share the current terminal
$ alpacon websh [SERVER NAME] --share
$ alpacon websh [SERVER NAME] --share --read-only true
# Join an existing shared session
$ alpacon websh join --url [SHARED_URL] --password [PASSWORD]Efficiently manage user and group resources:
# Managing Users
# List all users.
$ alpacon user ls / list / all
# Detailed user information.
$ alpacon user describe [USER NAME]
# Create a new user
$ alpacon user create
# Update the user information.
$ alpacon user update [USER NAME]
# Delete user
$ alpacon user delete [USER NAME]
$ alpacon user rm [USER NAME]
# Managing Groups
# List all groups.
$ alpacon group ls
# Detailed group information.
$ alpacon group describe [GROUP NAME]
# Delete group
$ alpacon group delete [GROUP NAME]
$ alpacon group rm [GROUP NAME]
# Add a member to a group with a specific role
$ alpacon group member add
$ alpacon group member add --group [GROUP NAME] --member [MEMBER NAME] --role [ROLE]
# Remove a member from a group
$ alpacon group member delete --group [GROUP NAME] --member[MEMBER NAME]
$ alpacon group member rm --group [GROUP NAME] --member [MEMBER NAME]API tokens can be used to access alpacon.
# Create a new API token
$ alpacon token create
$ alpacon token create -n [TOKEN NAME] -l / --limit=true
$ alpacon token create -n [TOKEN NAME] --expiration-in-days=7
# Display a list of API tokens in the Alpacon
$ alpacon token ls
# Delete API token
$ alpacon token delete [TOKEN_ID_OR_NAME]
$ alpacon token rm [TOKEN_ID_OR_NAME]
# Log in via API token
$ alpacon login -s [SERVER URL] -t [TOKEN KEY]Defines command access for API tokens and enables setting specific commands that each API token can run.
# Add a new command ACL with specific token and command.
$ alpacon token acl add [TOKEN_ID_OR_NAME]
$ alpacon token acl add --token=[TOKEN_ID_OR_NAME] --command=[COMMAND]
# Display all command ACLs for an API token.
$ alpacon token acl ls [TOKEN_ID_OR_NAME]
# Delete the specified command ACL from an API token.
$ alpacon token acl delete [COMMAND_ACL_ID]
$ alpacon token acl rm [COMMAND_ACL_ID]
$ alpacon token acl delete --token=[TOKEN_ID_OR_NAME] --command=[COMMAND]Facilitate file uploads and downloads:
$ alpacon cp [SOURCE] [DESTINATION]
# Upload files
$ alpacon cp /Users/alpacon.txt myserver:/home/alpacon/
# Download files
$ alpacon cp myserver:/home/alpacon/alpacon.txt .
# To use a specified username and groupname for the transfer:
$ alpacon cp -u [USER NAME] -g [GROUP NAME] [SOURCE] [DESTINATION][SERVER NAME]:[PATH]: denotes the server's name and the file's path for FTP operations.
Handle Python and system packages effortlessly:
# python
$ alpacon package python ls / list / all
$ alpacon package python upload alpamon-1.1.0-py3-none-any.whl
$ alpacon package python download alpamon-1.1.0-py3-none-any.whl .
# system
$ alpacon package system ls / list / all
$ alpacon package system upload osquery-5.10.2-1.linux.x86_64.rpm
$ alpacon package system download osquery-5.10.2-1.linux.x86_64.rpm .Retrieve and monitor server logs:
# View recent logs or tail specific logs.
$ alpacon logs [SERVER_NAME]
$ alpacon logs [SERVER NAME] --tail=10Retrieve and monitor events in the Alpacon:
# Display a list of recent events in the Alpacon
$ alpacon event
$ alpacon events
# Tail the last 10 events related to a specific server and requested by a specific user
$ alpacon event -t 10 -s myserver -u admin
$ alpacon event --tail=10 --server=myserver --user=adminManage server agents(Alpamon) with ease:
# Commands to control and upgrade server agents.
$ alpacon agent restart [SERVER NAME]
$ alpacon agent upgrade [SERVER NAME]
$ alpacon agent shutdown [SERVER NAME]Manage and view server notes:
# Display a list of all notes
$ alpacon note ls / list / all
$ alpacon note ls -s [SERVER NAME] --tail=10
# Create a note on the specified server
$ alpacon note create
$ alpacon note create -s [SERVER NAME] -c [CONTENT] -p [PRIVATE(true or false)]
# Delete a specified note
$ alpacon note delete [NOTE ID]
$ alpacon note rm [NOTE ID]Easily manage your private Certificate Authorities (CAs) and certificates:
# Create a new Certificate Authority
$ alpacon authority create
# List all Certificate Authorities
$ alpacon authority ls
# Get detailed information about a specific Certificate Authority.
$ alpacon authority describe [AUTHORITY ID]
# Download a root Certificate by authority's ID and save it to the specified file path.
$ alpacon authority download-crt [AUTHOIRY ID] --out=/path/to/root.crt
# Delete a CA along with its certificate and CSR
$ alpacon authority delete [AUTHORITY ID]
$ alpacon authority rm [AUTHORITY ID]
# Generate a new Certificate Signing Request (CSR)
$ alpacon csr create
# Display a list of CSRs, optionally filtered by status
$ alpacon csr ls
$ alpacon csr ls --status=signed
# Approve a Certificate Signing Request
$ alpacon csr approve [CSR ID]
# Deny a Certificate Signing Request
$ alpacon csr deny [CSR ID]
# Delete a Certificate Signing Request
$ alpacon csr delete [CSR ID]
$ alpacon csr rm [CSR ID]
# Get detailed information about a specific Signing Request.
$ alpacon csr describe [CSR ID]
# Download the signed certificate for a CSR
$ alpacon csr download-crt [CSR ID] --out=/path/to/certificate.crt
# List all certificates
$ alpacon cert ls
# Get detailed information about a specific Certificate.
$ alpacon cert describe [CERT ID]
# Download a specific Certificate by its ID and save it to the specified file path.
$ alpacon cert download [CERT ID] --out=/path/to/certificate.crtTo test the Alpacon CLI functionality, you can use the provided test script:
-
Copy the sample test script:
cp sample_test_cli.sh test_cli.sh
-
Edit the configuration variables to match your environment:
vi test_cli.sh
Update the following variables in the Configuration section:
# Configuration SERVER_NAME="your-server-name" # e.g., "amazon-linux-1" LOCAL_PATH="/your/local/path" # e.g., "/Users/username/Documents" REMOTE_ROOT_PATH="/root" # Usually "/root" REMOTE_USER_PATH="/your/remote/path" # e.g., "/home/username" WORKSPACE_URL="your-workspace-url" # e.g., "https://myworkspace.us1.alpacon.io"
-
Make the script executable and run the tests:
chmod +x test_cli.sh ./test_cli.sh
The test script will automatically:
- Check if you're logged in to Alpacon (and login if necessary)
- Create test files and folders locally
- Run comprehensive tests covering:
- Basic connectivity and server information
- Command execution (regular and root user)
- File upload/download operations
- Folder upload/download operations (recursive)
- Websh functionality
- Advanced operations and error handling
- Clean up all test files after completion
Test Coverage:
- 32 automated tests covering all major CLI functionality
- File and folder transfer operations
- Permission-based operations (user and root)
- SSH-style command syntax
- Error handling and edge cases
Note: Make sure you have access to the specified server and the necessary permissions for the test operations before running the script.
We welcome contributions! Here's how to get started:
git clone https://github.com/alpacax/alpacon-cli.git
cd alpacon-cli
go buildgo test ./...- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes
- Push to the branch and open a Pull Request
Bug reports and feature requests are welcome on our GitHub Issues page.
This project is licensed under the MIT License - see the LICENSE file for details.