Oc login: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Overview=
=Overview=


Establishes an authenticated command-line session with the server and saves configuration under <tt>.kube/config</tt>.If there is no state saved under .kube/config, it queries the user for OpenShift server, username and password.
'oc login' configures locally a [[.kube_config#Contexts|Kubernetes context]] by updating [[.kube_config|.kube/config]]. If it finds no state saved under .kube/config, or no command line options are provided, the command queries the user for OpenShift server, username and password. The command runs in the context of a project. The user must exists on server, and its identity must be correctly resolved by the OpenShift identity provider.
 
The command sets up the command line interface and serves as the entry point for most users.
 
The user must exists on server, and its identity must be correctly resolved by the OpenShift identity provider.


Example:
Example:
<syntaxhighlight lang='bash'>
oc login -u <username>:<password>
</syntaxhighlight>
<syntaxhighlight lang='bash'>
oc login <api-server-url> -u <username> -p <password>
</syntaxhighlight>


<pre>
If -u is not specified, 'oc login' will query for user.
oc login -u system:admin
</pre>
 
If -u is not specified, <tt>oc login</tt> will query for user.
 
More about authentication:


{{Internal|OpenShift_Security_Concepts#Authentication|OpenShift Security Concepts - Authentication}}
More about OpenShift authentication: {{Internal|OpenShift_Security_Concepts#Authentication|OpenShift Security Concepts &#124; Authentication}}


=Related=
=Related=
 
* [[oc whoami]]
[[oc whoami]]


=Options=
=Options=


==-u --username==
==-u,--username==


Sets the user name.
Sets the user name.


==-p --password==
==-p,--password==


Sets the user name.
Sets the password.


==-n==
==-n==
Line 41: Line 36:
Sets the project (namespace) to log into.
Sets the project (namespace) to log into.


==-s --server==
==-s,--server==
 
<syntaxhighlight lang='text'>
<pre>
oc login --server="https://my-openshift-master:8443" [...]
--server="https://my-openshift-master:8443"
</syntaxhighlight>
</pre>


==--certificate-authority==
==--certificate-authority==
Line 55: Line 49:
Allows interaction with HTTPS server while bypassing server certificate checks.
Allows interaction with HTTPS server while bypassing server certificate checks.


=Procedures=
=Operations=


* [[OpenShift Enable system:admin Remote Access|Enable system:admin Remote Access]]
* [[OpenShift Enable system:admin Remote Access|Enable system:admin Remote Access]]
=oc login and Azure OpenShift=
{{Internal|OpenShift_on_Azure#oc_login|OpenShift on Azure &#124; oc login}}

Latest revision as of 01:01, 20 November 2020

Internal

Overview

'oc login' configures locally a Kubernetes context by updating .kube/config. If it finds no state saved under .kube/config, or no command line options are provided, the command queries the user for OpenShift server, username and password. The command runs in the context of a project. The user must exists on server, and its identity must be correctly resolved by the OpenShift identity provider.

Example:

oc login -u <username>:<password>
oc login <api-server-url> -u <username> -p <password>

If -u is not specified, 'oc login' will query for user.

More about OpenShift authentication:

OpenShift Security Concepts | Authentication

Related

Options

-u,--username

Sets the user name.

-p,--password

Sets the password.

-n

Sets the project (namespace) to log into.

-s,--server

oc login --server="https://my-openshift-master:8443" [...]

--certificate-authority

Specifies the path to the certificate authority file.

--insecure-skip-tls-verify

Allows interaction with HTTPS server while bypassing server certificate checks.

Operations

oc login and Azure OpenShift

OpenShift on Azure | oc login