Telnet Terminal and Kubernetes Pod Terminal
An application of a portal can open a terminal on a device that only speaks Telnet, or in a container of a Kubernetes pod, right in the browser. Both work like the SSH terminal, with the differences below.
In short
Add an application with a telnet://host or kubernetes://api-server
upstream to a portal that is already served. Telnet has no encryption and
no identity to check, so use it only on the same network segment as the
gateway asset. A Kubernetes application names one pod; the gateway asset
signs in to the cluster's API server with a client certificate and
verifies the API server against the cluster's CA certificate, which is
required.
Telnet and Kubernetes compared with SSH
| SSH | Telnet | Kubernetes | |
|---|---|---|---|
| Upstream | ssh://host |
telnet://host |
kubernetes://api-server: the cluster's API server, not the pod |
| Default port | 22 | 23 | 6443 |
| Settings group in the editor | Terminal (SSH) | Terminal (Telnet) | Terminal (Kubernetes) |
| Sign-in the application can store | Username, Password, a key or a short-lived certificate | Username, Password or both, typed by the gateway asset at the target's prompts | Client certificate and Client key; nobody types an account |
| Identity check of the target | Host keys, or trust on first use | None: a Telnet server has no identity to verify, and nothing is encrypted | The API server's certificate, against the Cluster CA certificate |
| File transfer | SFTP | None | None |
| Recording | Yes, and a searchable transcript | Yes, and a searchable transcript | Yes, and a searchable transcript |
| Needs a current agent | Yes | An agent version that supports Telnet | An agent version that supports Kubernetes |
Every setting is described in Remote desktop settings; recordings in Sessions and recording.
Before you start
You need the same as for a remote desktop: a portal that is served, a current agent on its gateway asset that can download guacd, and a path from the gateway asset to the target. Saving a Telnet or Kubernetes application for a gateway asset with an older agent is refused; update the agent first.
-
Telnet: the gateway asset reaches the target's Telnet port, 23. Check on the gateway asset:
timeout 3 bash -c '</dev/tcp/192.168.1.40/23' && echo reachableTelnet sends everything in clear text, the password included, and the target cannot prove its identity. Use it only where the gateway asset sits in the same network segment as the target; see Telnet targets.
-
Kubernetes: the gateway asset reaches the cluster's API server, usually on port 6443. It needs no path to the pod network. Check on the gateway asset:
timeout 3 bash -c '</dev/tcp/10.0.0.10/6443' && echo reachableYou also need the cluster's CA certificate, and a client certificate with its key for a user that may open a terminal in the pod; see Prepare the cluster. A cluster that only takes tokens, for example the short-lived tokens of a cloud provider's sign-in plugin, cannot be used: the application signs in with a client certificate.
Publish a terminal (Telnet)
- Open the portal, choose Edit and, on the Applications tab, Add
application. Use the upstream
telnet://192.168.1.40, for example under the path prefix/switch, and the trust levelidentityortunnel. - The application shows the Terminal (Telnet) settings, with a warning that the session is not encrypted. Leave Username and Password empty to have people sign in at the target's own prompt in the terminal. To store the account, enter either or both: the gateway asset types them when the target asks, and the person never sees them.
- Only when the target asks in other words than
login:andpassword:, fill in Login prompt and Password prompt, for exampleUsername:orPIN:. See Telnet targets. - Save, and make sure a policy grants the portal.
- Open
https://<hostname>/switch/, sign in at your identity provider, and the terminal opens in the browser. There is no key to compare and nothing to pin.
Prepare the cluster
The application signs in as one user of the cluster, whoever opens it. Give that user the right to open a terminal in the one pod and nothing else.
-
Create a client certificate for a user, for example
xt-terminal, signed by the cluster's CA. With the cluster's own signer:openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \ -subj "/CN=xt-terminal" -keyout xt-terminal.key -out xt-terminal.csr kubectl apply -f - <<EOF apiVersion: certificates.k8s.io/v1 kind: CertificateSigningRequest metadata: {name: xt-terminal} spec: request: $(base64 < xt-terminal.csr | tr -d '\n') signerName: kubernetes.io/kube-apiserver-client usages: ["client auth"] EOF kubectl certificate approve xt-terminal kubectl get csr xt-terminal -o jsonpath='{.status.certificate}' | base64 -d > xt-terminal.crtThe key must have no passphrase. The certificate expires when the cluster says; note the date, and enter a new certificate with its key before then.
-
Allow the user to open the terminal in the pod. For an application with a Command, grant
pods/exec; for one without,pods/attach:apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: {namespace: prod, name: xt-terminal} rules: - apiGroups: [""] resources: ["pods/exec"] resourceNames: ["web-0"] verbs: ["get", "create"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: {namespace: prod, name: xt-terminal} subjects: - {kind: User, name: xt-terminal, apiGroup: rbac.authorization.k8s.io} roleRef: {kind: Role, name: xt-terminal, apiGroup: rbac.authorization.k8s.io} -
Get the cluster's CA certificate, the one that issued the API server's certificate:
kubectl config view --raw --minify \ -o jsonpath='{.clusters[0].cluster.certificate-authority-data}' | base64 -d > cluster-ca.crtThe file must hold exactly one certificate.
Publish a terminal in a pod (Kubernetes)
- Add an application with the upstream
kubernetes://10.0.0.10, the address of the API server as its certificate names it, for example under the path prefix/web-0, and the trust levelidentityortunnel. - The application shows the Terminal (Kubernetes) settings. Enter the
Pod, and the Namespace unless it is
default. Container is only needed for a pod with several containers. - Enter a Command to run in the container, usually
/bin/shor/bin/bash. Without a command, the session attaches to the container's main process, which only makes sense for a container started with a terminal. - Paste the Cluster CA certificate, the Client certificate and the Client key. The key is stored encrypted for the gateway asset and never shown again.
- Save, and make sure a policy grants the portal.
- The portal's detail page shows the result of the gateway asset's connection test under Remote desktop targets: Reachable, and the cluster accepts the client certificate, or what the API server refused.
- Open
https://<hostname>/web-0/. The terminal opens at once: nobody is asked for an account.
The pod's name is fixed in the application. That fits pods that keep their name, such as the pods of a StatefulSet or a pod started for maintenance, and not the pods of a Deployment, whose names change with every rollout.
Paste large texts in pieces: of several kilobytes pasted at once into a Kubernetes terminal, parts can go missing.
Verify
Open the application as a user the policy grants. The terminal opens in the
browser tab. Close the tab, and look in the event log for
web_app_desktop_session_started and web_app_desktop_session_ended, which
name the user, the target and the account. For a Kubernetes application the
target is the API server and the account is the name in the client
certificate; the cluster's own audit log shows that name for every session.
If it doesn't work
| What you see | Where to look |
|---|---|
| The agent of the gateway asset does not support Telnet applications yet; update it. (or Kubernetes) | Update the agent. |
| Telnet: the stored account is not typed, the terminal stays at the prompt | The target asks in other words than login: and password:. Set Login prompt and Password prompt. |
| Kubernetes: Refused: the API server's certificate does not verify against the route's CA certificate | The Cluster CA certificate is not the one that issued the API server's certificate, or the upstream uses a name or address the certificate does not carry. |
| Kubernetes: Refused: the cluster does not accept the client certificate | The certificate was not issued by a CA the cluster trusts for clients, or it expired. |
| Kubernetes: Refused: the cluster does not allow the client certificate's user to open a terminal in the pod | The role or its binding is missing, names another pod or namespace, grants only one of the verbs get and create, or grants pods/attach where the application has a Command (or the other way round). |
| The session ends with The connection failed. | Kubernetes: the pod or the container does not exist, or the command is not in the container. |
| Anything else | Portal messages and troubleshooting |
Next
- Record the sessions; the recording also gets a text transcript. See Sessions and recording.
- Give access for a limited time and with approval: Remote maintenance by an outside vendor.
See also
- Concept: Agentless Access
- Guide: SSH terminal and VNC screen
- Reference: Remote desktop settings, Using a portal