alexellis / alexellis/k3sup

Getting NODE_TOKEN with custom password protected ssh-key leads to too verbose NODE_TOKEN env var

Open
#420 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
7.4k
Forks
430
PR merge metrics
No merged PRs in 30d

Description

When fetching the NODE_TOKEN from first server with --ssh-key, the output in NODE_TOKEN also contains console output from the command itself where it asks for the passphrase.

## Why do you need this?
It's a small bug, because it brakes the automated scripts of k3sup and makes me edit the NODE_TOKEN env var after fetching it.

## Expected Behaviour
When fetching the NODE_TOKEN of the first server in the generated planned script via:

export NODE_TOKEN=$(k3sup node-token --host hostname.local --user myuser --ssh-key ~/mykeyfile)

I get a proper NODE_TOKEN

## Current Behaviour
Currently, the console outputs:

```
$ export NODE_TOKEN=$(k3sup node-token --host hostname.local --user myuser --ssh-key ~/mykeyfile)
Fetching: /etc/rancher/k3s/k3s.yaml
Remote: hostname.local:22
```

It then expects the passphrase for the key file but does not write that. I only saw it because the cursor turned into a key. After I typed the correct key, I get something back.
But echoing the $NODE_TOKEN is giving me:

```
$ echo $NODE_TOKEN
Enter passphrase for '/Users/myuser/mykeyfile':
K10dxxxxxxxxxxxxxxxxxxxxxx9c5816b8c7xxxxxxxxxx09f::server:a2xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

Somehow the output, that is expected to be shown in the terminal in sent to the env var.

## Possible Solution

## Steps to Reproduce

1. Create a setup script via k3sup plan with --ssh-key filled with password protected private key
2. run the install of the first server
3. fetch the NODE_TOKEN with --ssh-key inserted with passphrase protected private key file
4. echo the $NODE_TOKEN env var

## Your Environment

* k3sup version:

```
0.13.3
```

* What Kubernetes distribution, client and server version are you using?

```
kubectl version
```

* What OS or type or VM are you using for your cluster? Where is it hosted? (for `k3sup install/join`):

* Operating System and version (e.g. Linux, Windows, MacOS):

```
uname -a
Darwin MyMBP 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:43:05 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6020 arm64
cat /etc/os-release
cat: /etc/os-release: No such file or directory
```

## Do you want to work on this?

Subject to design approval, are you willing to work on a Pull Request for this issue or feature request?

- [ ] Yes
- [x] No

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.