How to Get The `juju ssh` Key From Juju API

My question is, how does the CLI set the user’s ssh key to the one that it generated, though?

My use case is that I need to do exactly what the CLI does for its SSH key, except I need to do it for Juju Lens. I need Juju Lens to be able to generate an SSH key and then tell Juju to associate that key with a logged in user so that the user will be able to use that key to ssh into machines that they have access to.

When a user logs-in with the CLI, the CLI is able to somehow register the random ssh key that it generated with the Juju user account so that the Juju controller will make sure that every model that the user has access to will trust the key that it placed in the users ~/.local dir.

The Juju CLI appears to be able to tell the Juju controller to associate a certain ssh key to a certain user, but I can’t figure out how to do that through the API according to this API documentation.

1 Like