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

'no start line' when running lit auth #300

Closed
NotNite opened this issue Nov 1, 2021 · 4 comments
Closed

'no start line' when running lit auth #300

NotNite opened this issue Nov 1, 2021 · 4 comments

Comments

@NotNite
Copy link

NotNite commented Nov 1, 2021

(Note: my setup is a bit cursed here, zsh on Windows via Git Bash; this isn't the fault of the error. I've tested this in PowerShell 5 and 7, same results.)

I'm trying out Luvit and went to run lit auth, when I was greeted with this rather cryptic error:

$ lit auth NotNite
lit version: 3.8.5
luvi version: v2.12.0
command: auth NotNite
load config: C:\Users\Julian\AppData\Roaming\litconfig
username: NotNite
name: NotNite
email: hi@notnite.com
privateKey: C:\Users\Julian\.ssh\lit
fail: [string "bundle:libs/core.lua"]:116: no start line
stack traceback:
        [C]: in function 'assert'
        [string "bundle:libs/core.lua"]:116: in function 'getKey'
        [string "bundle:libs/core.lua"]:357: in function 'authUser'
        [string "bundle:commands/auth.lua"]:63: in function <[string "bundle:commands/auth.lua"]:1>
        [string "bundle:main.lua"]:69: in function <[string "bundle:main.lua"]:56>
        [C]: in function 'xpcall'
        [string "bundle:main.lua"]:56: in function <[string "bundle:main.lua"]:48>

This is a fresh ssh-rsa key I just generated:

$ ssh-keygen -t rsa -C "lit"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Julian/.ssh/id_rsa): C:\Users\Julian\.ssh\lit
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in lit.
Your public key has been saved in lit.pub.

And a little test file recreating behavior:

local openssl = require("openssl")

local handle = io.open("C:\\Users\\Julian\\.ssh\\lit", "r")
local keyData = handle:read("*all")
handle:close()

local startsWithPrivKey = keyData:find("^-----BEGIN OPENSSH PRIVATE KEY-----") ~= nil
print("starts with private key: ", startsWithPrivKey)

local pkey = openssl.pkey.read(keyData, true)
print("pkey:", pkey)
print("openssl version:", openssl.version())
$ luvit test.lua
starts with private key:        true
pkey:   nil
openssl version:        0.7.8   Lua 5.1 OpenSSL 1.1.1g  21 Apr 2020

It's definitely a valid key, I was able to SSH into servers and pull Git repositories with it:

$ cat ~/.ssh/config | grep "Host github.com" -B 3
Host github.com
    Preferredauthentications publickey
    IdentityFile ~/.ssh/lit
    User git
$ git clone git@github.com:NotNite/NotNite.git
Cloning into 'NotNite'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 15 (delta 3), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), done.
Resolving deltas: 100% (3/3), done.

Am I doing something wrong? I know Lit requires RSA keys and assumes ~/.ssh/id_rsa to be the path of the file, but:

  • the lit key is RSA. I tried using my main Git key first (which is ed25519), but it gave the same error.
  • I tried moving the key to ~/.ssh/id_rsa just in case and just got the same error, without a prompt for the path this time.

Since I got the same error from my ed25519 key, I'm assuming this is because it's failing to parse it. Why it would be, I have no clue.

(Also, uh, anyone there? The newest issue was last interacted with 29 days ago... is this abandoned? I can't tell...)

@Bilal2453
Copy link
Contributor

Yeah, I've noticed this issue like a month ago or so, it is not a bug. Here how it goes:

  1. Lit only accept PEM body armor.
  2. OpenSSH at some point changed the default of keygen.
  3. Due to that, in order to make it work with Lit you need to generate it with keygen -t rsa -b 4096 -C "your_email@example.com" -m PEG (notice the -m PEM).

@Bilal2453
Copy link
Contributor

Bilal2453 commented Nov 1, 2021

And I can definitely guarantee you it is not abandoned xD

edit: I will be making a change on the Wiki to indicate this nowadays required flag to keygen

@NotNite
Copy link
Author

NotNite commented Nov 1, 2021

That worked! Thank you so much!

$ ssh-keygen -t rsa -b 4096 -m PEM -C "lit"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Julian/.ssh/id_rsa): ./lit
./lit already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./lit.
Your public key has been saved in ./lit.pub.
$ lit auth notnite
lit version: 3.8.5
luvi version: v2.12.0
command: auth notnite
load config: C:\Users\Julian\AppData\Roaming\litconfig
username: notnite
name: NotNite
email: hi@notnite.com
privateKey: C:\Users\Julian\.ssh\lit
# omitted because i'm not sure if this is private or not lol
update config: C:\Users\Julian\AppData\Roaming\litconfig
done: success
$

Thanks for also changing the wiki, I'm sure it'll save some other tired developers trying to make individual keys.

@NotNite NotNite closed this as completed Nov 1, 2021
@truemedian
Copy link
Member

For clarification for any further users who make it here: openssh's ssh-keygen command defaults to outputting public and private keys in the RFC4716 "SSH Public Key File Format" rather than the older RFC1421 PEM format that lit auth expects.

This can be fixed by passing along the -m PEM flag which will generate the "correct" key format.

Another thing to note is that even with the fall in popularity in RSA keys in favor of ED25519, RSA currently remains as the only way to use lit auth

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

No branches or pull requests

3 participants