nextcloud notes

mounting external storage over sftp

The trick using private/public keys is to strip header, footer and newlines from the key. This is not documented (seemingly, in early 2024) so I found it via a reddit post ().

Geneate a key pair (on any machine) - it has to be RSA! Use password or not.

ssh-keygen -t rsa -f .ssh/nextcloud_key

Copy public key to .ssh/authorized_keys on your host that you want to mount into nextcloud:

ssh-copy-id -i .ssh/nextcloud_key USERNAME@HOSTNAME.TLD

Remove header, footer and any newlines from private key:

sed '/OPENSSH/d' .ssh/nextcloud_key | tr -d '\n'

In nexcloud settings > External storage, choose SFT and RSA Private Key.

Copy the line of the private key (from above - without headers/footers and newlines) into the 'private key' field. Fill out other fields.

This is not necessary but if you use multiple public keys in authorized_keys file on the server you can edit the last line (user@host) to something more sensible.