Raybeam provides a REST API for managing SSH public keys with LDAP-based authentication. The API supports dual response formats:
- text/plain (default): SSH authorized_keys format, ideal for scripting
- application/json: Structured JSON responses, ideal for applications
All endpoints that require authentication use HTTP Basic Auth with LDAP credentials.
http://your-server:8080
Most endpoints require HTTP Basic Authentication using LDAP credentials:
curl -u username:password http://your-server:8080/users/@me/ssh-keys- Public: No authentication required
- Authenticated: Valid LDAP credentials required
- Admin: Authenticated user must be in the configured admin LDAP group
The @me alias represents the currently authenticated user:
# List your own keys
curl -u alice:password http://your-server:8080/users/@me/ssh-keysMany endpoints support comma-separated sAMAccountNames for batch operations:
# Get keys for multiple users
curl http://your-server:8080/users/alice,bob,charlie/ssh-keysReturns version and repository information.
Endpoint: GET /info
Authentication: None
Response Format: JSON only
Response:
{
"version": "c95e75c",
"source": "https://github.com/netresearch/raybeam"
}Example:
curl http://your-server:8080/infoList all SSH keys for the authenticated user.
Endpoint: GET /users/@me/ssh-keys
Authentication: Required (user)
Response Formats: text/plain, application/json
Response (text/plain):
# Keys uploaded by "CN=Alice,OU=Users,DC=example,DC=com"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFq...
Response (application/json):
{
"success": true,
"keys": {
"SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA": {
"fingerprint": "SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...\n"
}
}
}Example:
# Get text/plain format
curl -u alice:password http://your-server:8080/users/@me/ssh-keys
# Get JSON format
curl -u alice:password -H "Accept: application/json" \
http://your-server:8080/users/@me/ssh-keysUpload a new SSH public key for the authenticated user.
Endpoint: PUT /users/@me/ssh-keys
Authentication: Required (user)
Content-Type: text/plain
Response Formats: text/plain, application/json
Request Body:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ... user@hostname
Response (application/json):
{
"success": true
}Status Codes:
201 Created: Key uploaded successfully401 Unauthorized: Authentication failed500 Internal Server Error: Key already exists or validation failed
Example:
# Upload key from file
curl -u alice:password -T ~/.ssh/id_rsa.pub \
http://your-server:8080/users/@me/ssh-keys
# Upload key inline
curl -u alice:password -X PUT \
-d "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ..." \
http://your-server:8080/users/@me/ssh-keysNotes:
- Key comments are automatically removed during upload
- Duplicate keys (same fingerprint) are rejected
- Key is validated using golang.org/x/crypto/ssh parser
Retrieve a specific SSH key by fingerprint for the authenticated user.
Endpoint: GET /users/@me/ssh-keys/:fingerprint
Authentication: Required (user)
Response Formats: text/plain, application/json
Path Parameters:
fingerprint: SHA256 fingerprint (e.g.,SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA)
Response (text/plain):
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...
Response (application/json):
{
"success": true,
"key": {
"fingerprint": "SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...\n"
}
}Status Codes:
200 OK: Key found401 Unauthorized: Authentication failed404 Not Found: Key not found
Example:
# Generate fingerprint
ssh-keygen -l -E sha256 -f ~/.ssh/id_rsa.pub
# Get key by fingerprint
curl -u alice:password \
http://your-server:8080/users/@me/ssh-keys/SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HADelete a specific SSH key by fingerprint for the authenticated user.
Endpoint: DELETE /users/@me/ssh-keys/:fingerprint
Authentication: Required (user)
Response Formats: text/plain, application/json
Path Parameters:
fingerprint: SHA256 fingerprint
Response (application/json):
{
"success": true
}Status Codes:
200 OK: Key deleted successfully401 Unauthorized: Authentication failed500 Internal Server Error: Deletion failed
Example:
curl -u alice:password -X DELETE \
http://your-server:8080/users/@me/ssh-keys/SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HADelete all SSH keys for the authenticated user.
Endpoint: DELETE /users/@me/ssh-keys
Authentication: Required (user)
Response Formats: text/plain, application/json
Response (application/json):
{
"success": true
}Status Codes:
200 OK: All keys deleted successfully401 Unauthorized: Authentication failed500 Internal Server Error: Deletion failed
Example:
curl -u alice:password -X DELETE \
http://your-server:8080/users/@me/ssh-keysList all SSH keys for one or more users (comma-separated).
Endpoint: GET /users/:sAMAccountNames/ssh-keys
Authentication: None (public read)
Response Formats: text/plain, application/json
Path Parameters:
sAMAccountNames: Single user or comma-separated list (e.g.,aliceoralice,bob,charlie)
Response (text/plain):
# Keys uploaded by "CN=Alice,OU=Users,DC=example,DC=com"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...
# Keys uploaded by "CN=Bob,OU=Users,DC=example,DC=com"
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFq...
Response (application/json):
{
"success": true,
"keys": {
"CN=Alice,OU=Users,DC=example,DC=com": {
"SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA": {
"fingerprint": "SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...\n"
}
},
"CN=Bob,OU=Users,DC=example,DC=com": {
"SHA256:different_fingerprint": {
"fingerprint": "SHA256:different_fingerprint",
"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFq...\n"
}
}
}
}Status Codes:
200 OK: Keys retrieved successfully404 Not Found: One or more users not found in LDAP
Example:
# Get keys for single user
curl http://your-server:8080/users/alice/ssh-keys
# Get keys for multiple users
curl http://your-server:8080/users/alice,bob,charlie/ssh-keys
# Get JSON format
curl -H "Accept: application/json" \
http://your-server:8080/users/alice,bob/ssh-keysUpload a SSH public key for one or more users. Requires admin privileges unless uploading for self.
Endpoint: PUT /users/:sAMAccountNames/ssh-keys
Authentication: Required (admin or self)
Content-Type: text/plain
Response Formats: text/plain, application/json
Path Parameters:
sAMAccountNames: Single user or comma-separated list
Authorization:
- If
sAMAccountNamesmatches authenticated user: self-service allowed - Otherwise: authenticated user must be in admin LDAP group
Request Body:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ... user@hostname
Response (application/json):
{
"success": true
}Status Codes:
201 Created: Key(s) uploaded successfully401 Unauthorized: Authentication failed403 Forbidden: Not authorized (not admin or self)404 Not Found: One or more users not found in LDAP500 Internal Server Error: Upload failed
Example:
# Admin uploads key for multiple users
curl -u admin:password -T ~/.ssh/id_rsa.pub \
http://your-server:8080/users/alice,bob,charlie/ssh-keys
# Self-service upload (same as @me endpoint)
curl -u alice:password -T ~/.ssh/id_rsa.pub \
http://your-server:8080/users/alice/ssh-keysRetrieve a specific SSH key by fingerprint for one or more users.
Endpoint: GET /users/:sAMAccountNames/ssh-keys/:fingerprint
Authentication: None (public read)
Response Formats: text/plain, application/json
Path Parameters:
sAMAccountNames: Single user or comma-separated listfingerprint: SHA256 fingerprint
Response (text/plain):
# Keys uploaded by "CN=Alice,OU=Users,DC=example,DC=com"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...
# Keys uploaded by "CN=Bob,OU=Users,DC=example,DC=com"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...
Response (application/json):
{
"success": true,
"keys": {
"CN=Alice,OU=Users,DC=example,DC=com": {
"fingerprint": "SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...\n"
}
}
}Status Codes:
200 OK: Key found404 Not Found: Key not found or user(s) not found
Example:
curl http://your-server:8080/users/alice,bob/ssh-keys/SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HADelete a specific SSH key by fingerprint for one or more users. Requires authentication.
Endpoint: DELETE /users/:sAMAccountNames/ssh-keys/:fingerprint
Authentication: Required (user or admin)
Response Formats: text/plain, application/json
Path Parameters:
sAMAccountNames: Single user or comma-separated listfingerprint: SHA256 fingerprint
Authorization:
- Authenticated user can delete their own keys
- Admin can delete any user's keys
Response (application/json):
{
"success": true
}Status Codes:
200 OK: Key(s) deleted successfully401 Unauthorized: Authentication failed404 Not Found: User(s) not found500 Internal Server Error: Deletion failed
Example:
# User deletes own key
curl -u alice:password -X DELETE \
http://your-server:8080/users/alice/ssh-keys/SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HA
# Admin deletes keys for multiple users
curl -u admin:password -X DELETE \
http://your-server:8080/users/alice,bob/ssh-keys/SHA256:hSZQXa36JqMa2L3TRhc0t6RHSXVO3gy6rYx7RrVS2HADelete all SSH keys for one or more users. Requires admin privileges.
Endpoint: DELETE /users/:sAMAccountNames/ssh-keys
Authentication: Required (admin)
Response Formats: text/plain, application/json
Path Parameters:
sAMAccountNames: Single user or comma-separated list
Authorization:
- Authenticated user must be in admin LDAP group
Response (application/json):
{
"success": true
}Status Codes:
200 OK: Keys deleted successfully401 Unauthorized: Authentication failed403 Forbidden: Not in admin group404 Not Found: One or more users not found500 Internal Server Error: Deletion failed
Example:
# Delete all keys for multiple users
curl -u admin:password -X DELETE \
http://your-server:8080/users/alice,bob,charlie/ssh-keysRaybeam supports two response formats based on the Accept header:
text/plain (default):
- Used when
Acceptheader is not set or set totext/plain - Returns SSH keys in authorized_keys format
- Ideal for direct use with SSH:
curl http://server/users/alice/ssh-keys >> ~/.ssh/authorized_keys
application/json:
- Used when
Accept: application/jsonheader is present - Returns structured JSON with success status and data/error fields
- Ideal for programmatic API consumption
authorization header not found
{
"success": false,
"error": "authorization header not found"
}| Message | Meaning |
|---|---|
authorization header not found |
Basic Auth header missing |
authorization was not in the format of 'username:password' |
Malformed Basic Auth header |
authorization failed |
Invalid LDAP credentials or user not found |
not in admin group |
User authenticated but not in admin group |
user "<sAMAccountName>" not found |
Specified user doesn't exist in LDAP |
ssh key not found |
Specified fingerprint doesn't exist for user |
could not parse SSH key |
Invalid SSH public key format |
SSH key already uploaded |
Key with same fingerprint already exists |
internal server error |
Database or LDAP communication error |
# 1. Upload your SSH public key
curl -u alice:password -T ~/.ssh/id_rsa.pub \
http://your-server:8080/users/@me/ssh-keys
# 2. Verify upload
curl -u alice:password http://your-server:8080/users/@me/ssh-keys# Add to authorized_keys directly
curl http://your-server:8080/users/alice/ssh-keys >> ~/.ssh/authorized_keys
# Or for multiple users (e.g., team access)
curl http://your-server:8080/users/alice,bob,charlie/ssh-keys >> ~/.ssh/authorized_keys# 1. Generate new key pair
ssh-keygen -t ed25519 -f ~/.ssh/id_new
# 2. Upload new key
curl -u alice:password -T ~/.ssh/id_new.pub \
http://your-server:8080/users/@me/ssh-keys
# 3. Test new key access
ssh -i ~/.ssh/id_new user@target-server
# 4. Delete old key
OLD_FP=$(ssh-keygen -l -E sha256 -f ~/.ssh/id_rsa.pub | awk '{print $2}')
curl -u alice:password -X DELETE \
http://your-server:8080/users/@me/ssh-keys/$OLD_FP# Upload same key for multiple users
curl -u admin:password -T team_key.pub \
http://your-server:8080/users/alice,bob,charlie/ssh-keys
# Remove all keys for departing team members
curl -u admin:password -X DELETE \
http://your-server:8080/users/former_employee1,former_employee2/ssh-keysRaybeam does not currently implement rate limiting. Consider using a reverse proxy (nginx, Traefik) for rate limiting in production deployments.
Raybeam does not provide built-in TLS/HTTPS support. In production:
- Deploy behind a TLS-terminating reverse proxy (nginx, Traefik, Caddy)
- Never expose Basic Auth over unencrypted HTTP in production
- Consider using mTLS for additional security
Raybeam does not currently implement API versioning. The API is considered stable but may evolve in future releases. Check the /info endpoint for current version.