Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Feature Requests
  3. Improving user experience with SSH keys for SSHFS and volume mounts

Improving user experience with SSH keys for SSHFS and volume mounts

Scheduled Pinned Locked Moved Feature Requests
1 Posts 1 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jadudmJ Offline
    jadudmJ Offline
    jadudm
    wrote last edited by
    #1

    feature statement

    As a user, I want copy-paste to "just work" when pasting SSH private keys into Cloudron.

    context

    When setting up SSHFS, either for backups or volume mounts, a private key is needed. These typically have the form

    -----BEGIN OPENSSH PRIVATE KEY-----
    MULTIPLE/ASDFLAKSJDFLKAJASDFLKJASDF
    LINES/ASDFASDFKLJASDLFJKSADFLKJASDF
    OF/ASDFLKJASDFLKJASDFLKJASDFLJKASDL
    BASE64/ASDFJKLASDFLKJASDLFJKASDFLKJ
    DATA/ANDPADDING=
    -----END OPENSSH PRIVATE KEY-----
    

    As a user, I might be copy-pasting this from a number of places.

    1. I might cat a private key on my terminal, and have to use a three-key sequence (CTRL-SHIFT-C) to copy
    2. I might cat a private key in a web terminal, and have to CTRL-INS to copy (because that is how the web terminal is configured)
    3. I might use Bitwarden/Vaultwarden, and have it generate a keypair for me. That key will then have a "copy icon" that I can click for both the public and private keys
    4. I might use a web gui in another product (e.g. TrueNAS Scale) to generate the keys, and copy-paste out of a web text area

    In each case, the way whitespace is handled may vary.

    Further, it appears (based on skimming things on the web) that SSH defines the protocol, but there are not good definitions for how SSH keys should be stored. That is, the bytestream representation for communicating them between client and server is specified, but it is a bit up-in-the-air as to how they should be stored at rest.

    On inspection, it looks like it is common for a MIME encoding to be used on the Base64 content. Base64 does not consider __ (that's a space) to be a valid character. Some encodings, like MIME, specify maximum line lengths, but the use of spaces/newlines/etc. as separators should be ignored.

    https://en.wikipedia.org/wiki/Base64

    (Apologies for not linking to authoritative sources/RFCs.)

    the problem

    Long story short: when I paste a private key into Cloudron, I am pasting a lot of text into a small text area. How whitespaces or linebreaks are or are not used once I hit "Save" or "Submit" is invisible to me as a user. However, it is clear that it has impact.

    1. When I copy-paste and carefully preserve line breaks, it appears to work.
    2. When I use Bitwarden, and copy-paste from an auto-generated keypair, it appears to fail.

    replicating the error

    1. Go to your Bitwarden install
    2. Generate and save an SSH keypair
    3. Copy the private key
    4. Create an SSHFS volume mount
    5. Paste in the private key
    6. On another system, add the public key to the authorized_keys file
    7. It should fail.

    It is also possible that there is some kind of subtle user error taking place; however, I'm uncertain where to look in my Cloudron instance to debug this under the covers.

    what i want as a user

    I want things to "just work."

    In this case, I would like Cloudron to either:

    1. Warn me my key is not well-formatted, or
    2. Make a best effort to format the key appropriately behind-the-scenes

    If I paste something like this (the Bitwarden example):

    -----BEGIN OPENSSH PRIVATE KEY----- MULTIPLE/ASDFLAKSJDFLKAJASDFLKJASDF LINES/ASDFASDFKLJASDLFJKSADFLKJASDF ... -----END OPENSSH PRIVATE KEY-----
    

    with whitespaces instead of newlines, I expect Cloudron to write it to disk replacing my spaces with newlines, so it becomes:

    -----BEGIN OPENSSH PRIVATE KEY-----
    MULTIPLE/ASDFLAKSJDFLKAJASDFLKJASDF
    LINES/ASDFASDFKLJASDLFJKSADFLKJASDF ... 
    -----END OPENSSH PRIVATE KEY-----
    

    if that is necessary to "make it just work." Or, I expect it to complain, and tell me the format is invalid. Either way, I don't want to be able to paste a key and then have SSH failures that are inscrutable. (SSHFS mount failed for unknown reason, or whatever the vague error case is.)

    other solutions I'd think work for me as a user

    I'd also be happy to:

    1. Have Cloudron generate the keypair for me, and let me copy the key(s) (pub/priv) to my local machine. Or, you could put them on a page and say "copy these and don't lose them." Either way, if you control key generation, you guarantee that I can't mess them up. (Or, if I mess them up elsewhere, that's my problem, not yours).
    2. Upload a file for the key. It would be OK if I uploaded the keyfile. This way, I can inspect it on disk, and the upload process won't (shouldn't?) mangle the file en route.

    The spirit here is that I'm excited about anything that doesn't have invisible errors.

    fun find

    https://superuser.com/questions/1444319/how-to-check-ssh-key-version-locally

    You can do

    ssh-keygen -l -f <file>
    

    and if it is a valid pub or priv keyfile, it will spit out

    <bits> <SHA> <comment> (<type>)
    

    which may be a good check to add to the backend after writing the key. Then, you could either get a valid SHA, or you could say "Could not generate SHA of SSH key; see <docs> for more info."

    side note: types of key

    Some (probably poorly written) systems only accept RSA keys (vs ED25519, etc.). This probably has to do with OpenSSL version(s) that are installed.

    If there are any known limitations to Cloudron's use of pub/priv keypairs (e.g. "Cloudron can only use RSA keys up to 2048 bits"), then that should be communicated to the user up front. I think Cloudron is fine with any valid kind of SSH key, but that would be invisible to me at the moment.

    I use Cloudron on a Dell 7040 I bought on eBay.

    1 Reply Last reply
    3
    • jadudmJ jadudm referenced this topic
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Bookmarks
    • Search