|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * cli_reference/openshift_cli/getting-started.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="cli-logging-in-web_{context}"] |
| 7 | += Logging in to the OpenShift CLI using a web browser |
| 8 | + |
| 9 | +You can log in to the OpenShift CLI (`oc`) with the help of a web browser to access and manage your cluster. This allows users to avoid inserting their access token into the command line. |
| 10 | + |
| 11 | +[WARNING] |
| 12 | +==== |
| 13 | +Logging in to the CLI through the web browser runs a server on localhost with HTTP, not HTTPS; use with caution on multi-user workstations. |
| 14 | +==== |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | + |
| 18 | +* You must have access to an {product-title} cluster. |
| 19 | +* You must have installed the OpenShift CLI (`oc`). |
| 20 | +* You must have a browser installed. |
| 21 | +
|
| 22 | +.Procedure |
| 23 | + |
| 24 | +. Enter the `oc login` command with the `--web` flag: |
| 25 | ++ |
| 26 | +[source,terminal] |
| 27 | +---- |
| 28 | +$ oc login <cluster_url> --web <1> |
| 29 | +---- |
| 30 | +<1> If needed, you can specify the callback port and server URL. |
| 31 | + |
| 32 | +. The web browser opens automatically. If it does not, click the link in the command output. If you do not specify the {product-title} server `oc` tries to open the web console of the cluster specified in the current `oc` configuration file. If no `oc` configuration exists, `oc` prompts interactively for the server URL. |
| 33 | ++ |
| 34 | +.Example output |
| 35 | + |
| 36 | +[source,terminal] |
| 37 | +---- |
| 38 | +Opening login URL in the default browser: https://openshift.example.com |
| 39 | +Opening in existing browser session. |
| 40 | +---- |
| 41 | ++ |
| 42 | +.Example |
| 43 | + |
| 44 | +[source,terminal] |
| 45 | +---- |
| 46 | +$ oc login <https://api.your-openshift-server.com> --web --callback-port 8280 localhost:8443 |
| 47 | +---- |
| 48 | +. If more than one identity provider is available, select your choice from the options provided. |
| 49 | + |
| 50 | +. Enter your username and password into the corresponding browser fields. After you are logged in, the browser displays the text `access token received successfully; please return to your terminal`. |
| 51 | + |
| 52 | +. Check the CLI for a login confirmation. |
| 53 | ++ |
| 54 | +.Example output |
| 55 | + |
| 56 | +[source,terminal] |
| 57 | +---- |
| 58 | +Login successful. |
| 59 | +
|
| 60 | +You don't have any projects. You can try to create a new project, by running |
| 61 | +
|
| 62 | + oc new-project <projectname> |
| 63 | +
|
| 64 | +---- |
| 65 | + |
| 66 | +[NOTE] |
| 67 | +==== |
| 68 | +The web console defaults to the profile used in the previous session. To switch between Administrator and Developer profiles, log out of the {product-title} web console and clear the cache. |
| 69 | +==== |
| 70 | + |
| 71 | +You can now create a project or issue other commands for managing your cluster. |
0 commit comments