Login to OpenShift Origin

There are quite a few ways to login into openshift through the oc cli. Let us explore them one by one.

1. Interactive Login with Credentials

To Simply login use oc login. This will prompt for username and password, providing which it will authenticate and log you in.

1
2
3
4
5
6
$ oc login
Server[https://localhost:8443]:
username: snmaddula
password:

Login Successful.

You can specify the Server URL in-line:

1
$ oc login https://localhost:8443

2. Non-Interactive Login with Credentials (a.k.a one-liner)

To login by providing username and password in-line :

1
oc login -u=snmaddula -p=secret

To instantly switch to a particular namespace / project on successful login :

1
oc login -u=snmaddula -p=secret -n=project1

In the above examples, -u is short for --username as -p is for --password and -n for --namespace