elitak / nixos-infect

[GPLv3+] install nixos over the existing OS in a DigitalOcean droplet (and others with minor modifications)
GNU General Public License v3.0
1.3k stars 214 forks source link

SSH key extraction doesn't work with ssh-import-id #196

Open Noratrieb opened 6 months ago

Noratrieb commented 6 months ago

I used ssh-import-id-gh Nilstrieb which results in /root/.ssh/authorized_keys containing

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG0n1ikUG9rYqobh7WpAyXrqZqxQoQ2zNJrFPj12gTpP Nilstrieb@github/87124356 # ssh-import-id gh:Nilstrieb

Then running sed -E 's/^.*((ssh|ecdsa)-[^[:space:]]+)[[:space:]]+([^[:space:]]+)([[:space:]]*.*)$/\1 \3\4/' /root/. ssh/authorized_keys (the sed monster extracted from https://github.com/elitak/nixos-infect/blob/9c5b46d78eb0b108e8ed48a1497be968f7754722/nixos-infect#L23) over it returns this:

ssh-import-id gh:Nilstrieb

not exactly what we want.

On Contabo Ubuntu 22.04 running sed (GNU sed) 4.8