Search code examples
openshiftopenshift-client-toolsopenshift-4

Unable to login to openshift with CLI


I'm trying to login to starter openshift server. Then getting error:

C:\Users\Admin>oc login https://console-openshift-console.apps.us-west-1.online-starter.openshift.com
error: invalid character '<' looking for beginning of value

version of CLI:

C:\Users\Admin>oc version
Client Version: version.Info{Major:"4", Minor:"1+", GitVersion:"v4.1.1", GitCommit:"4b47d3394", GitTreeState:"clean", BuildDate:"2019-06-05T20:42:01Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"windows/amd64"}

"About" in Openshift 4 online: Kubernetes Master Version v1.13.4+81fc896

full stacktrace of error:

C:\Users\Admin>oc login https://console-openshift-console.apps.us-west-1.online-starter.openshift.com --loglevel=9
I0610 15:30:13.242674    6768 round_trippers.go:419] curl -k -v -XHEAD  'https://console-openshift-console.apps.us-west-1.online-starter.openshift.com:443/'
I0610 15:30:14.731741    6768 round_trippers.go:438] HEAD https://console-openshift-console.apps.us-west-1.online-starter.openshift.com:443/ 200 OK in 1459 milliseconds
I0610 15:30:14.741867    6768 round_trippers.go:444] Response Headers:
I0610 15:30:14.742863    6768 round_trippers.go:447]     Date: Mon, 10 Jun 2019 12:30:14 GMT
I0610 15:30:14.742863    6768 round_trippers.go:447]     Content-Type: text/html; charset=utf-8
I0610 15:30:14.743861    6768 round_trippers.go:447]     Cache-Control: private
I0610 15:30:14.743861    6768 round_trippers.go:447]     X-Content-Type-Options: nosniff
I0610 15:30:14.744858    6768 round_trippers.go:447]     Set-Cookie: csrf-token=Y5HTi5JEtyltd27b7VgaS3tC0jpkYk2WWHqibPSa4tRsh0TJgt0k6fzfZdQTZMawO0rLB6nLNINqNmYTAtqUPQ==; Path=/; Secure
I0610 15:30:14.744858    6768 round_trippers.go:447]     Set-Cookie: 1e2670d92730b515ce3a1bb65da45062=c13f251446e70d52cfdceee5ed73bcbb; path=/; HttpOnly; Secure
I0610 15:30:14.744858    6768 round_trippers.go:447]     X-Dns-Prefetch-Control: off
I0610 15:30:14.745855    6768 round_trippers.go:447]     X-Frame-Options: DENY
I0610 15:30:14.745855    6768 round_trippers.go:447]     X-Xss-Protection: 1; mode=block
I0610 15:30:14.745855    6768 round_trippers.go:447]     Referrer-Policy: strict-origin-when-cross-origin
I0610 15:30:14.746857    6768 request_token.go:92] SSPI Enabled
I0610 15:30:14.746857    6768 round_trippers.go:419] curl -k -v -XGET  -H "X-Csrf-Token: 1" 'https://console-openshift-console.apps.us-west-1.online-starter.openshift.com:443/.well-known/oauth-authorization-server'
I0610 15:30:15.085208    6768 round_trippers.go:438] GET https://console-openshift-console.apps.us-west-1.online-starter.openshift.com:443/.well-known/oauth-authorization-server 200 OK in 338 milliseconds
I0610 15:30:15.085208    6768 round_trippers.go:444] Response Headers:
I0610 15:30:15.086206    6768 round_trippers.go:447]     X-Dns-Prefetch-Control: off
I0610 15:30:15.086206    6768 round_trippers.go:447]     Date: Mon, 10 Jun 2019 12:30:14 GMT
I0610 15:30:15.087203    6768 round_trippers.go:447]     Cache-Control: private
I0610 15:30:15.087203    6768 round_trippers.go:447]     Content-Type: text/html; charset=utf-8
I0610 15:30:15.088200    6768 round_trippers.go:447]     Referrer-Policy: strict-origin-when-cross-origin
I0610 15:30:15.088200    6768 round_trippers.go:447]     Set-Cookie: csrf-token=nowDCVVg+iMNf9Ldc6MldQJwsIgg8Tltk5djsue2h3uZy7woy7F1b0SfTQkv1Lw2kO3cs+82mOFOgE0Io5VUGQ==; Path=/; Secure
I0610 15:30:15.088200    6768 round_trippers.go:447]     Set-Cookie: 1e2670d92730b515ce3a1bb65da45062=a7f4fcdbc17050ff7e35cf025b9ceaf2; path=/; HttpOnly; Secure
I0610 15:30:15.089199    6768 round_trippers.go:447]     X-Content-Type-Options: nosniff
I0610 15:30:15.089199    6768 round_trippers.go:447]     X-Frame-Options: DENY
I0610 15:30:15.090228    6768 round_trippers.go:447]     X-Xss-Protection: 1; mode=block
I0610 15:30:15.090228    6768 negotiator_sspi.go:135] Attempt to release SSPI
F0610 15:30:15.090228    6768 helpers.go:116] error: invalid character '<' looking for beginning of value

What I'm doing wrong?


Solution

  • You should login using api URL, not console URL, such as https://console-openshift-console.apps.us-west-1.online-starter.openshift.com. api URL is using 6443 port by default.

    # oc login https://<api url>:6443
    

    UPDATE:

    AFAIK, api URL is configured in kubeconfig auth file by default. And you can usually login without specifying api URL as follows.

    # export KUBECONFIG=/home/user_id/install/auth/kubeconfig
    # oc login
    

    Usually, api URL format is api.<cluster name>.<domain>.

    Refer OpenShift 4: Install Experience for more details.