Commit Graph

7 Commits (22c2473e3ea9bfae05316753d7bc00f744077828)

Author SHA1 Message Date
Dustin d443542ee0 user/login: Add cert to SSH agent
dustin/sshca-cli/pipeline/pr-master There was a failure building this commit Details
dustin/sshca-cli/pipeline/head This commit looks good Details
An SSH certificate is useless on its own, as without the private key,
clients cannot sign servers' authentication requests.  Since `sshca-cli
user login` creates a new key pair each time it is run, the private key
needs to be kept at least as long as the certificate is valid.  To that
end, the command will now add both to the user's SSH agent.  It
communicates with the agent via the UNIX stream socket specified by the
`SSH_AUTH_SOCK` environment variable.

Although there is a Rust crate, [ssh-agent-client-rs][0] that implements
the client side of the SSH agent protocol, it does not support adding
certificates to the agent.  In fact, that functionality is not even
documented in the IETF draft specification for the protocol.  Thus, I
had to figure it out by reading the code of the OpenSSH `ssh-add` tool,
and observing the messages passed between it and `ssh-agent`.

[0]: https://crates.io/crates/ssh-agent-client-rs
2024-01-31 17:41:58 -06:00
Dustin 123ca813a7 user/login: Request signed cert from SSHCA
The `sshca-cli user login` command now requests a signed certificate
from the SSHCA server.  Given a valid OpenID Connect identity token and
an SSH public key, the server will return a signed certificate, valid
for a predetermined (usually short) period of time.  The principals
listed in the certificate are derived from the ID token.
2024-01-31 17:40:14 -06:00
Dustin 3b55f7418e user: Add sshca user login command
The `sshca user login` command will eventually provide the command-line
interface for obtaining user SSH certificates.  It initiates the OAuth2
login process, retreiving an OpenID Connect Identity Token from the
OpenID Server.  This token will be submitted to the SSHCA server to
authorize a request to sign a certificate.  For now, though, the token
is printed to standard output, e.g. to be used in a `curl` request.
2023-11-21 20:13:17 -06:00
Dustin c26d67a25b main: Factor out get_sshca_server_url function
The `get_sshca_server_url` function encapsulates the logic of
identifying the URL of the SSHCA server.  For now, it only considers the
`SSHCA_SERVER` environment variable, but eventually, it will also
support other configuration methods like a configuration file.  Moving
this to a separate function will allow other areas of the code to share
the same logic.
2023-11-20 18:23:35 -06:00
Dustin 1d0e558163 Add SSHCA_CLI_DEBUG_TEST_MACHINE_ID env var
When running a debug build, the `sshca host sign` command will now check
the `SSHCA_CLI_DEBUG_TEST_MACHINE_ID` environment variable for the value
to use as the machine ID.  This is useful during development and
testing, where the real machine ID is inaccessible or otherwise
unavailable.

The `SSHCA_CLI_DEBUG_TEST_MACHINE_ID` environment variable is *NOT* used
at all in release builds.
2023-11-16 20:12:38 -06:00
Dustin d8126a6dcb cli: Trim trailing null from RPi serial
The `/sys/firmware/devicetree/base/serial-number` pseudo-file has a
trailing null byte, which causes `Uuid::parse_srr` to fail.  This makes
it impossible to authenticate Raspberry Pi devices to the server.  The
trailing byte needs to be removed before attempting to parse the serial
number into a UUID to avoid this problem.
2023-11-12 10:44:48 -06:00
Dustin b203bbd87c cli: Begin CLI client
The CLI tool will be the primary method for interacting with the SSH CA
service.  For now, it supports a single operation: `sshca-cli host
sign`, which requests a certificate to be signed by the CA service.`
2023-11-05 10:31:58 -06:00