kubeconfig - oc commands: error: You must be logged in to the server (Unauthorized) in OCP 4

Solution Verified - Updated -

Issue

  • Unable to run any oc commands using KUBECONFIG variable.
  • Unable to run any oc commands using the --kubeconfig=<path> option.
  • All oc commands throws the following error:

    error: You must be logged in to the server (Unauthorized)
    

Environment

  • Red Hat OpenShift Container Platform (RHOCP)
    • 4
  • oc client tool

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content