origin icon indicating copy to clipboard operation
origin copied to clipboard

unable to login with `system:admin`

Open surajnarwade opened this issue 8 years ago • 7 comments

$ oc login https://127.0.0.1:8443 -u system:admin
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y

Authentication required for https://127.0.0.1:8443 (openshift)
Username: system:admin
Password: 
error: username system:admin is invalid for basic auth

surajnarwade avatar Sep 24 '18 06:09 surajnarwade

Now magically it worked,

$ oc login -u system:admin
Logged into "https://127.0.0.1:8443" as "system:admin" using existing credentials.

You have access to the following projects and can switch between them with 'oc project <projectname>':

    default
    kube-dns
    kube-proxy
    kube-public
    kube-service-catalog
    kube-system
  * myproject
    openshift
    openshift-apiserver
    openshift-automation-service-broker
    openshift-controller-manager
    openshift-core-operators
    openshift-infra
    openshift-node
    openshift-template-service-broker
    openshift-web-console

Using project "myproject".

can someone please explain reason or cure for this flaky behavior?

surajnarwade avatar Sep 24 '18 06:09 surajnarwade

system:admin is cert based user. login just uses the correct context if you have it available:

$ export KUBECONFIG=<...>/openshift.local.config/master/admin.kubeconfig

$ oc config get-contexts 
CURRENT   NAME                                      CLUSTER              AUTHINFO                          NAMESPACE
*         default/192-168-43-69:8443/system:admin   192-168-43-69:8443   system:admin/192-168-43-69:8443   default

$ oc config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://192.168.43.69:8443
  name: 192-168-43-69:8443
contexts:
- context:
    cluster: 192-168-43-69:8443
    namespace: default
    user: system:admin/192-168-43-69:8443
  name: default/192-168-43-69:8443/system:admin
current-context: default/192-168-43-69:8443/system:admin
kind: Config
preferences: {}
users:
- name: system:admin/192-168-43-69:8443
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

enj avatar Sep 24 '18 13:09 enj

what if I dont have kubeconfig and I did,

oc login https://127.0.0.1:8443 -u system:admin

what will happen ?

surajnarwade avatar Sep 25 '18 07:09 surajnarwade

what if I dont have kubeconfig and I did,

oc login https://127.0.0.1:8443 -u system:admin

what will happen ?

It will fail since you cannot get a token for system:admin. You must have the correct kubeconfig file already available for it to switch to the appropriate user.

enj avatar Sep 25 '18 10:09 enj

Can't connect with system:admin , the result of oc config view is :

apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://192.168.99.100:8443
  name: 192-168-99-100:8443
- cluster:
    certificate-authority: C:\Users\Slim\.minikube\ca.crt
    server: https://192.168.99.100:8443
  name: minikube
contexts:
- context:
    cluster: 192-168-99-100:8443
    user: admin/192-168-99-100:8443
  name: /192-168-99-100:8443/admin
- context:
    cluster: 192-168-99-100:8443
    user: dev/192-168-99-100:8443
  name: /192-168-99-100:8443/dev
- context:
    cluster: 192-168-99-100:8443
    user: system/192-168-99-100:8443
  name: /192-168-99-100:8443/system
- context:
    cluster: minikube
    user: minikube
  name: minikube
- context:
    cluster: 192-168-99-100:8443
    namespace: myproject
    user: developer/192-168-99-100:8443
  name: myproject/192-168-99-100:8443/developer
current-context: /192-168-99-100:8443/system
kind: Config
preferences: {}
users:
- name: admin/192-168-99-100:8443
  user:
    token: xxx
- name: dev/192-168-99-100:8443
  user:
    token: xyx
- name: developer/192-168-99-100:8443
  user:
    token: zycv
- name: minikube
  user:
    client-certificate: C:\Users\Slim\.minikube\client.crt
    client-key: C:\Users\Slim\.minikube\client.key
- name: system/192-168-99-100:8443
  user:
    token: dfsds

How can I fix that?

slim-hmidi avatar Jun 27 '20 12:06 slim-hmidi

In my case, I just had to login in superuser context to run the command so that it can pick up the right certificate for automatic authentication credentials. Use "sudo" in front of your command as in "sudo oc login https://127.0.0.1:8443 -u system:admin"

sunil-mhc avatar Jul 05 '20 20:07 sunil-mhc

sudo oc login -u system:admin

turek737 avatar Jun 14 '21 15:06 turek737