Skip to content

Commit 5a05673

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

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
<style>
27+
.gist .gist-file {
28+
background-color: #1e1e1e !important;
29+
color: #f8f8f2 !important;
30+
}
31+
</style>
32+
33+
<script src="https://gist.github.com/dsariel/a68bdb55784f23b59f64aa6a6929b73d.js"></script>
34+
35+
# ------------------------------
36+
37+
38+
39+
```bash
40+
<!-- Embed script from raw GitHub content -->
41+
curl -s https://raw.githubusercontent.com/dsariel/scripts/master/OpenShift/relogin.sh | cat
42+
43+
```
44+
45+
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:
46+
47+
## Steps to Obtain a New Token
48+
49+
1. **Install a Text-Based Browser**\
50+
Install `lynx`, a command-line browser, to access the token request page:
51+
52+
```bash
53+
sudo yum install lynx -y
54+
```
55+
56+
2. **Retrieve a password for the `kubeadmin` user**\
57+
If you are using the default `kubeadmin` user, retrieve the password from the installation directory:
58+
59+
```bash
60+
cat ~/.kube/kubeadmin-password
61+
```
62+
63+
Use this password to log in as `kubeadmin` in the browser interface during the next stage.
64+
65+
3. **Access the Token Request Page**\
66+
Use `lynx` to navigate to the token request page:
67+
68+
```bash
69+
lynx https://oauth-openshift.apps.ocp.openstack.lab/oauth/token/request
70+
```
71+
72+
4. **Obtain a New Token**\
73+
Once logged in, obtain a new token. The login command will look like this:
74+
75+
```bash
76+
oc login --token=sha256~<...> --server=https://api.ocp.openstack.lab:6443
77+
```
78+
79+

0 commit comments

Comments
 (0)