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

Use better UI for adding authorized_keys #629

Open
spotlesscoder opened this issue Aug 27, 2023 · 5 comments
Open

Use better UI for adding authorized_keys #629

spotlesscoder opened this issue Aug 27, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@spotlesscoder
Copy link

I started using rpi-imager not too long ago.

As I rarely do setup of ssh servers, I don't know what the proper contents of the authorized keys field should look like in rpi-imager.
Currently, the field is only a single line text input which is quite short. It is not clear to me, which parts of my newly generated public ssh public key (ssh-keygen on linux commandline) I need to paste into that field.
The input field should assist me by indicating whether the pasted string looks like a valid public key.

Also, it should be capable of accepting multiple public keys, e.g. when a friend gives me his public key so I can give that person access too while setting up a new raspi installation.

So the input field should also offer a way of adding multiple ssh keys one after the other and also giving me an indication about how many valid keys I already entered. So when I would see a label like "2 valid keys entered", I would immediately see that the setup seems to be correct in that case.

@spotlesscoder spotlesscoder changed the title Add better UI for adding authorized_keys Use better UI for adding authorized_keys Aug 27, 2023
@lurch
Copy link
Contributor

lurch commented Aug 27, 2023

See also #326 and #316

@maxnet
Copy link
Collaborator

maxnet commented Aug 27, 2023

As I rarely do setup of ssh servers, I don't know what the proper contents of the authorized keys field should look like in rpi-imager.

If you are using Linux or Mac OS X it will automatically fill in the contents of ~/.ssh/id_rsa.pub and you do not have to copy it manually.
Perhaps we should look into doing the same for Windows, but more complicated there as we are not running under normal username but as admin, and user may not be using the official ssh client -which Windows does ship nowadays- but something third-party like Putty...

@spotlesscoder
Copy link
Author

I was actually using Linux in that situation. There was nothing I noticed that was telling me the rpi-imager would automatically pick up the id_rsa.pub. I also don't think that this is a good idea because I want to actively decide which keys should be allowed on the raspi and no magic happen in the background that would violate privacy or integrity of the key/the raspberry install without the user actively giving permission to add a certain key to the raspberry

@maxnet
Copy link
Collaborator

maxnet commented Aug 27, 2023

There was nothing I noticed that was telling me the rpi-imager would automatically pick up the id_rsa.pub.

It will pre-fill the contents of ssh key box, but you will still need to check the "enable ssh" -> "allow public key only" boxes before it has any effect...
Up to you to remove your own key in that case, if you like to only give your neighbour access to your Pi and not yourself...
Just like it pre-fills the username that you are logged in as on the computer running Imager, but it will only be used if you click "Set username and password", and you are welcome to change it...
Same with wifi...

If you did not notice it filled something in, then you probably did not generate a key with normal OpenSSH command-line tools ("ssh-keygen"), but are using something non-standard (e.g. Putty).
(Or have saved Imager settings previously, before the key existed. If saved settings are used, they are pre-filled instead of information from your system)

@tdewey-rpi tdewey-rpi added the enhancement New feature or request label Feb 8, 2024
@Blueshawk
Copy link

Blueshawk commented Nov 3, 2024

You should not assume the key in .ssh is appropriate. For starters, those are often bundled with the system and so are widely open to abuse and should be replaced. Also, many of us use more than one set of keys for various systems and have them named and in directories. Overwriting keys already in system is also problematic.

A good way to fix this would be to have rpi-imager run ssh_keygen and place the private key in the new system, but place your pub key in the home dir or giving it a name like "hostname.ecdsa" in ~/.ssh or a line in the setup. indicating such in a dialog. Including a quick instruction like $ssh [IPaddress] -i ~/.ssh/hostname.ecdsa" in the setup dialog would help folks as well.

Also worth noting rsa is now sus and not default in ssh.

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

No branches or pull requests

5 participants