Skip to content

Commit 103e018

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

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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="iframe.php?url=https://github.com/dsariel/scripts/blob/master/OpenShift/relogin.sh" width="100%" height="400px"></iframe>
21+
22+
23+
24+
# ------------------------------
25+
26+
27+
<iframe
28+
src="https://raw.githubusercontent.com/dsariel/scripts/refs/heads/master/OpenShift/relogin.sh"
29+
style="width:100%; height:300px;"
30+
></iframe>
31+
32+
# ------------------------------
33+
34+
<script>
35+
fetch("https://raw.githubusercontent.com/dsariel/scripts/master/OpenShift/relogin.sh")
36+
.then(response => response.text())
37+
.then(data => {
38+
document.getElementById("script-content").textContent = data;
39+
});
40+
</script>
41+
42+
<pre id="script-content">Loading...</pre>
43+
44+
45+
# OpenShift Token Refresh
46+
47+
48+
```html
49+
<style>
50+
.gist .gist-file {
51+
background-color: #a8a2a2 !important;
52+
color: #f548f2 !important;
53+
}
54+
</style>
55+
56+
<script src="https://gist.github.com/dsariel/a68bdb55784f23b59f64aa6a6929b73d.js"></script>
57+
```
58+
59+
# ------------------------------
60+
61+
62+
63+
```bash
64+
<!-- Embed script from raw GitHub content -->
65+
curl -s https://raw.githubusercontent.com/dsariel/scripts/master/OpenShift/relogin.sh | cat
66+
67+
```
68+
69+
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:
70+
71+
## Steps to Obtain a New Token
72+
73+
1. **Install a Text-Based Browser**\
74+
Install `lynx`, a command-line browser, to access the token request page:
75+
76+
```bash
77+
sudo yum install lynx -y
78+
```
79+
80+
2. **Retrieve a password for the `kubeadmin` user**\
81+
If you are using the default `kubeadmin` user, retrieve the password from the installation directory:
82+
83+
```bash
84+
cat ~/.kube/kubeadmin-password
85+
```
86+
87+
Use this password to log in as `kubeadmin` in the browser interface during the next stage.
88+
89+
3. **Access the Token Request Page**\
90+
Use `lynx` to navigate to the token request page:
91+
92+
```bash
93+
lynx https://oauth-openshift.apps.ocp.openstack.lab/oauth/token/request
94+
```
95+
96+
4. **Obtain a New Token**\
97+
Once logged in, obtain a new token. The login command will look like this:
98+
99+
```bash
100+
oc login --token=sha256~<...> --server=https://api.ocp.openstack.lab:6443
101+
```
102+
103+

0 commit comments

Comments
 (0)