Recover access via command line

Hi,
I have the admin account and password of my juju controller , i can access via the web interface .
I have a ssh access on the controller .
I changed my laptop , and my folder .local/share/juju/ is empty .
My controller is version 2.4.1 .

How i can regain my access via command line ?

I think that ‘juju login -- help’ will show you an example of pointing the client to your controller API endpoint and that would perhaps get you starting.

However, your (lost?) private ssh keys are perhaps going to cause you issues later.

Let’s see if someone else can chip in.

1 Like

@erik-lonroth is right on point. Juju login is your next step, although being at 2.4.1 might be an issue as much of that login work went in after that I believe.

Hmmm, if you can’t ssh into the machines it’s going to be difficult to get things like the controller cert. Basically I’d try to bootstrap a new controller and look at the data in .local/share/juju/controllers.yaml and you’ll see the details that you need to connect and work against the controller.

If you start to go through that and hit something we can’t get we’ll have to see if there’s any work arounds.

I was able to recover my access by :
create a a folder .local/share/juju
create a file controllers.yaml with this data

controllers:
    <LOCAL_NAME_OF_JUJU>:
    uuid: <CREATE_A_NEW_UUID_IN_LOWER_CASE>
    api-endpoints: ['<IP_OF_YOUR_JUJU_API_CONTROLLER>:17070']
    ca-cert: |
      -----BEGIN CERTIFICATE-----
      <CERT_FROM_YOUR_JUJU_CONTROLLER>
      -----END CERTIFICATE-----

 generate a new uuid with : 

uuidgen | tr '[:upper:]' '[:lower:]'

 fetch the cert with openssl 
 openssl s_client -host  <IP_OF_YOUR_CONTROLLER> -port 17070  < /dev/null 2>&1 | openssl  x509 -inform pem -outform pem

and after i was able to do juju login , and juju status , but i can not do juju ssh

1 Like

Right, so from here see if you can add a new ssh key using the normal juju commands juju ssh-import-id or juju add-ssh-key. It should add the key to the existing machines. You’ll need to do that per model.