Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beginner issue: what is the format for the authorized user keys in config.yaml? #63

Closed
wychwitch opened this issue Jan 20, 2022 · 17 comments · Fixed by #64
Closed

Beginner issue: what is the format for the authorized user keys in config.yaml? #63

wychwitch opened this issue Jan 20, 2022 · 17 comments · Fixed by #64

Comments

@wychwitch
Copy link

Hello! I know this is a beginner's issue, but I've been pulling my hair out over trying to get user keys working.

The example lists this format for creating authorized users:

users:
  - name: Beatrice
    admin: true
    public-keys:
      - KEY TEXT

To me, KEY TEXT was vague, and ended up trying the following options without success:

  1. copy and pasted the full public SSH key (in rsa format)
  2. name of the public SSH key file in .ssh
  3. full path to the public ssh key file in .ssh

Every time I got the error bad yaml in config.yaml: yaml: line 25: did not find expected key

I know I'm missing something obvious, is there a specific file that the ssh key needs to be stored in first? Is the format incorrect? Any help would be great.

I'm running soft on a debian server, and I installed using homebrew.

@caarlos0
Copy link
Member

it should be in the authorized keys format, e.g.

public-keys:
  - ssh-rsa AAAAB3Nz... # etc
  - ssh-ed25519 AAAA... # etc

@wychwitch
Copy link
Author

it should be in the authorized keys format, e.g.

public-keys:
  - ssh-rsa AAAAB3Nz... # etc
  - ssh-ed25519 AAAA... # etc

Ah that's what I thought! It didn't seem to work for me... Let me try again, maybe I had a small typo

@wychwitch
Copy link
Author

Ah now since I can't launch soft due to the config error, I have no way to push the new config changes to the soft git server...

Is there a way to launch soft in some sort of 'safe' mode, or to simple wipe everything and start again? I'm assuming simply deleting the ~/.repos/config repo would do that, but I want to make sure before I break things even more haha

@caarlos0
Copy link
Member

can you share your config?

you should be able to clone it locally with:

git clone ~/.repos/config config
cat config/config.yaml

judging by bad yaml in config.yaml: yaml: line 25: did not find expected key, my guess is something is not well-aligned and YAML is not liking it... (maybe mixed tabs and spaces?)

That said, yes, you can simply delete the config repo.

@caarlos0 caarlos0 reopened this Jan 20, 2022
@caarlos0
Copy link
Member

(sorry, didn't mean to close it yet)

@wychwitch
Copy link
Author

can you share your config?

you should be able to clone it locally with:

git clone ~/.repos/config config
cat config/config.yaml

judging by bad yaml in config.yaml: yaml: line 25: did not find expected key, my guess is something is not well-aligned and YAML is not liking it... (maybe mixed tabs and spaces?)

That said, yes, you can simply delete the config repo.

Cloning it locally worked! I'm not sure why that didn't occur to me hahaha

Committed and pushed again and it works now! I'm guessing I just accidentally included a tab or something that yaml didn't like when I first tried using the RSA format.

Thanks so much!! I was not expecting to be helped this quickly! I'm excited to continue exploring the charmbracelet ecosystem ^^

@caarlos0
Copy link
Member

caarlos0 commented Jan 20, 2022

ah, amazing!

glad I could help 😊

since its fixed, will close, feel free to reopen/comment if needed 🙏

@wychwitch
Copy link
Author

ah, amazing!

glad I could help 😊

since its fixed, will close, feel free to reopen/comment if needed 🙏

OH OOPS sorry to reopen this but it turns out it wasn't working after all?? I thought it was when it launched again after committing directly to the ./repos/config, but after changing the config to a different username it threw the same error as before

can you share your config?

Yes, here it is!

# The name of the server to show in the TUI.
name: Soft Serve

# The host and port to display in the TUI. You may want to change this if your
# server is accessible from a different host and/or port that what it's
# actually listening on (for example, if it's behind a reverse proxy).
host: localhost
port: 23338

# Access level for anonymous users. Options are: read-write, read-only and
# no-access.
anon-access: read-only

# You can grant read-only access to users without private keys. Any password
# will be accepted.
allow-keyless: false

# Customize repo display in the menu. Only repos in this list will appear in
# the TUI.
repos:
  - name: Home
    repo: config
    private: true
    note: "Configuration and content repo for this server"

 users:
   - name: wych
     admin: true
     public-keys:
       - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCcd/CLuQY7Li7IRzlheg3fL32ZjMbCZ/N6PuHZXnW95M3KttwjlGsnDTt5GQXWGfarmIFhLogN0i3rajDp8ctBf7dsbN+3nY1wbSufgD7rl6n6wz4lyXAfUZM7/gjoS7gomcq1k1FtJ9G9HyUeY3BQGeM7XOm+0kXzlBmxRfBqI2UmelkqX8p5CeNELZmxcuMAdbxSdUHZ4apc1pPUQP1TxHwMj4qQaudsva9+Hxqp42ZInsIcKX3popwayXDAGzPL3t5lVorGaam/fPl7MENXQhHjYz0kdY4frI3n8SqI8ZSQ14jDPjwDddYy+7VZFOAcrOV44YfiJT3sBL0lSVtXamd2WXuufsyf6Py2v8Z8j5MGPLbKPlRtWzpn6cB5/aBKqhcb2+LsaYeNkNxRWE3KZVK0R6/wNpCRjfQv6E18lc/5S3lIBvRqTke0RJxhrIpZCRVJWuluS61ZXqkd/+tYmynk0PdEqkGBO9e7lMh791kHxTq6jBDtP1/BmvFrhgM=
#   - name: Example User
#     collab-repos:
#       - REPO
#     public-keys:
#       - KEY TEXT

@wychwitch
Copy link
Author

I see the issue!! Users was indented a space when I was removing the #'s around it. I'll fix it!

@wychwitch
Copy link
Author

wychwitch commented Jan 20, 2022

okay i have a NEW issue, one I'll make into a new thread in a bit if it's needed

After deleting the .repos/config folder, running soft again does not seem to recreate it like I'm assuming it should?? After making an error I decided to delete it to start from complete scratch, but now I can't edit the config.

Sorry to annoy you again @caarlos0, but is there another step after deleting the repo to regenerate it? I'm sorry for all the trouble 😓

@meowgorithm
Copy link
Member

Hi, @wychwitch! I work with Carlos. I'm not able to reproduce this via soft on main on Linux and macOS. That is, I'm finding that if I run the following…

soft
rm -rf .repos/config
soft

…the config repo will be re-created. Do you mind double checking? Also, what platform are you on?


Some internal references:

I believe the config repo will be created on startup if it doesn't exist here:

err := c.createDefaultConfigRepo(yaml)

…via this method:

func (cfg *Config) createDefaultConfigRepo(yaml string) error {

@wychwitch
Copy link
Author

Hi, @wychwitch! I work with Carlos. I'm not able to reproduce this via soft on main on Linux and macOS. That is, I'm finding that if I run the following…

soft
rm -rf .repos/config
soft

…the config repo will be re-created. Do you mind double checking? Also, what platform are you on?

Some internal references:

I believe the config repo will be created on startup if it doesn't exist here:

err := c.createDefaultConfigRepo(yaml)

…via this method:

func (cfg *Config) createDefaultConfigRepo(yaml string) error {

Weird! When I try that now, I get the following error:

soft
2022/01/20 16:43:11 repository does not exist

Then it immediately quits. I'm running debian 10!

If it makes any difference, I tried using docker in the meantime to see if I that would work better (it didn't, for other reasons not relevant for this right now)

Thank you both for the help!!

@wychwitch
Copy link
Author

…the config repo will be re-created. Do you mind double checking? Also, what platform are you on?

Oh sorry!! I thought I answered this, yes, I checked and ~./repos is empty completely

@meowgorithm
Copy link
Member

How odd. And this is happening on a normal partition (not on, say, a networked partition or in /tmp)?

Also, does it work if you mv .repos .old-repos entirely?


It looks like the error is happening here:

log.Fatal(err)

Specifically here:

rg, err := git.PlainInit(rp, bare)

(Since the error is coming from go-get)

@wychwitch
Copy link
Author

wychwitch commented Jan 21, 2022

How odd. And this is happening on a normal partition (not on, say, a networked partition or in /tmp)?

Yes! This was in my home folder.

Also, does it work if you mv .repos .old-repos entirely?

That worked!! I was able to clone the config repo, edited it to include an admin user and commit/pushed it! However, I am unable to access the server from other computers on my local network.

On the server itself I can still clone the config repo just fine, or ssh to itself. But when I try on another computer, I get a password prompt that always denies no matter what I put in there.

To be clear, this is how I'm attempting to clone from the server:

git clone ssh://[email protected]:23231/config config

I made sure to set the soft host to 192.168.XXX.XXX:23231, as shown below in the config.yaml

# The name of the server to show in the TUI.
name: Soft Serve!

# The host and port to display in the TUI. You may want to change this if your
# server is accessible from a different host and/or port that what it's
# actually listening on (for example, if it's behind a reverse proxy).
host: 192.168.XXX.XXX
port: 23231

# Access level for anonymous users. Options are: read-write, read-only and
# no-access.
anon-access: read-write

# You can grant read-only access to users without private keys. Any password
# will be accepted.
allow-keyless: false

# Customize repo display in the menu. Only repos in this list will appear in
# the TUI.
repos:
  - name: Home
    repo: config
    private: true
    note: "Configuration and content repo for this server"

users:
  - name: wych
    admin: true
    public-keys:
      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCcd/CLuQY7Li7IRzlheg3fL32ZjMbCZ/N6PuHZXnW95M3KttwjlGsnDTt5GQXWGfarmIFhLogN0i3rajDp8ctBf7dsbN+3nY1wbSufgD7rl6n6wz4lyXAfUZM7/gjoS7gomcq1k1FtJ9G9HyUeY3BQGeM7XOm+0kXzlBmxRfBqI2UmelkqX8p5CeNELZmxcuMAdbxSdUHZ4apc1pPUQP1TxHwMj4qQaudsva9+Hxqp42ZInsIcKX3popwayXDAGzPL3t5lVorGaam/fPl7MENXQhHjYz0kdY4frI3n8SqI8ZSQ14jDPjwDddYy+7VZFOAcrOV44YfiJT3sBL0lSVtXamd2WXuufsyf6Py2v8Z8j5MGPLbKPlRtWzpn6cB5/aBKqhcb2+LsaYeNkNxRWE3KZVK0R6/wNpCRjfQv6E18lc/5S3lIBvRqTke0RJxhrIpZCRVJWuluS61ZXqkd/+tYmynk0PdEqkGBO9e7lMh791kHxTq6jBDtP1/BmvFrhgM=
#   - name: Example User
#     collab-repos:
#       - REPO
#     public-keys:
#       - KEY TEXT

Also, does the name put in the config.yaml have to match the username of the user actually running the program with the soft command? I would like to sign in under a different username for security, but if that's not possible, I could just create another user. If it makes a difference, in this example I set the username to be the same as he user running the program just in case.

@meowgorithm
Copy link
Member

What address are you binding soft to? Keep in mind that the host setting in the config is only for display purposes. Can you try the following?

SOFT_SERVE_HOST=0.0.0.0 ./soft

The username in the config is just for your internal record keeping. Users will connect via Soft Serve's internal SSH server, which will run on the host as whichever user is running soft. If security is a concern you'll probably want to run Soft Serve as an unprivileged user as you suggest. Also, because keys are used for identity and the user argument is irrelevant to Soft Serve, you can drop the user argument from the clone command:

git clone ssh://192.168.XXX.XXX:23231/config

@wychwitch
Copy link
Author

wychwitch commented Jan 21, 2022

What address are you binding soft to? Keep in mind that the host setting in the config is only for display purposes. Can you try the following?

SOFT_SERVE_HOST=0.0.0.0 ./soft

The username in the config is just for your internal record keeping. Users will connect via Soft Serve's internal SSH server, which will run on the host as whichever user is running soft. If security is a concern you'll probably want to run Soft Serve as an unprivileged user as you suggest. Also, because keys are used for identity and the user argument is irrelevant to Soft Serve, you can drop the user argument from the clone command:

git clone ssh://192.168.XXX.XXX:23231/config

HUH.. I tried it again on my other computer and it worked! I thought it might've had something to do with my other computer using cygwin, so I installed it and it STILL worked!

I ran ssh -v. and it turns out I'm encountering the same issue as #48 No mutual signature algorithm error.

I guess this is solved? I can continue providing more info or logs in that issue instead!

For what it's worth, running OFT_SERVE_HOST=0.0.0.0 ./soft didn't change anything but I figure that's to be expected lmao

Sorry for this being such a saga!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants