Skip to content

Commit 12b1384

Browse files
committed
[post] HOWTO: Obtain new Openshift token from Xterm
1 parent b981afb commit 12b1384

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
layout: post
3+
title: HOWTO Obtain new Openshift token from Xterm
4+
date: 2025-02-14 09:15:16
5+
description: OpenShift login token expired because tokens are, by default, valid for a limited time (e.g., 24 hours). Follow these steps to obtain a new token and continue working with the cluster.
6+
tags: OpenShift token xterm CLI text-web-browser lynx
7+
categories: OpenShift
8+
---
9+
10+
# How to Obtain a New Token for OpenShift from xterm
11+
12+
OpenShift login tokens expire because they are, by default, valid for a limited time (e.g., 24 hours). One way to obtain a new token is by SSHing into the controller machine and
13+
running the [relogin.sh script](https://github.com/dsariel/scripts/blob/master/OpenShift/relogin.sh). See the content below:
14+
15+
16+
# OpenShift Token Refresh
17+
18+
OpenShift login tokens expire because they are, by default, valid for a limited time (e.g., 24 hours). One way to obtain a new token is by SSHing into the controller machine and running the relogin.sh script.
19+
20+
<iframe src="https://github.com/dsariel/scripts/blob/master/OpenShift/relogin.sh" width="100%" height="400px"></iframe>
21+
22+
# ------------------------------
23+
24+
# OpenShift Token Refresh
25+
26+
<script src="https://gist.github.com/dsariel/a68bdb55784f23b59f64aa6a6929b73d.js"></script>
27+
28+
# ------------------------------
29+
30+
31+
32+
```bash
33+
<!-- Embed script from raw GitHub content -->
34+
curl -s https://raw.githubusercontent.com/dsariel/scripts/master/OpenShift/relogin.sh | cat
35+
36+
```
37+
38+
and using a text-based web browser on the remote server if connecting via the web console is not an option. Follow these steps to obtain a new token and continue working with the cluster:
39+
40+
## Steps to Obtain a New Token
41+
42+
1. **Install a Text-Based Browser**\
43+
Install `lynx`, a command-line browser, to access the token request page:
44+
45+
```bash
46+
sudo yum install lynx -y
47+
```
48+
49+
2. **Retrieve a password for the `kubeadmin` user**\
50+
If you are using the default `kubeadmin` user, retrieve the password from the installation directory:
51+
52+
```bash
53+
cat ~/.kube/kubeadmin-password
54+
```
55+
56+
Use this password to log in as `kubeadmin` in the browser interface during the next stage.
57+
58+
3. **Access the Token Request Page**\
59+
Use `lynx` to navigate to the token request page:
60+
61+
```bash
62+
lynx https://oauth-openshift.apps.ocp.openstack.lab/oauth/token/request
63+
```
64+
65+
4. **Obtain a New Token**\
66+
Once logged in, obtain a new token. The login command will look like this:
67+
68+
```bash
69+
oc login --token=sha256~<...> --server=https://api.ocp.openstack.lab:6443
70+
```
71+
72+
73+

0 commit comments

Comments
 (0)