An SSH key lets you log in to a server without typing a password, and it is much harder to guess or steal than one. You can make the key on the phone itself. Nothing has to be created on a computer and copied across.
A key comes in two halves. The private key stays on your iPhone and is never shown to anyone. The public key is a single line of text that you add to a file on the server. When you connect, the server checks that your phone holds the matching private half. The public key is safe to paste, email or share; the private key is not.
Malvek creates an Ed25519 key pair, the type OpenSSH itself now creates by default. The private half is stored in the iOS Keychain on the phone. The public key appears straight away, with Copy and Share buttons. You can see it again at any time by tapping the key in the list.
A public key looks like this, all on one line:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...restOfKey
Pick whichever of these fits your server.
mkdir -p ~/.ssh && chmod 700 ~/.ssh
echo 'PASTE-PUBLIC-KEY-HERE' >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Use >> (two arrows), which adds a line.
A single > would replace the file and remove any keys
already in it.
DigitalOcean, Hetzner, Linode, Vultr, AWS Lightsail and most other providers let you paste a public key in their dashboard, either on the account or when creating a server. Copy the key in Malvek, paste it there, and new servers come up with it already installed. On many providers this only applies to servers created afterwards, so use option A for a server that already exists.
Tap Share and send the public key to the administrator
by email or chat. It is safe to send. They add it to your account's
authorized_keys file.
Optional hardening: once key login works, you can turn off
password logins on the server. Set PasswordAuthentication no
in /etc/ssh/sshd_config and restart sshd. Keep your current
session open and test the key from a second connection first, so a typo
can't lock you out.
If you'd rather use the key from your laptop, open the Keys tab and tap the import button in the top bar.
id_ed25519 from the Files app. AirDrop it to the phone or
save it to iCloud Drive first.OpenSSH, RSA and EC private keys are supported. If the key has a passphrase, you're asked for it once during import. Afterwards the key is protected by the iOS Keychain instead.
A separate key per device is the safer habit. If the phone
is lost, you remove one line from authorized_keys and your
laptop's key keeps working.
The private key exists only on that device. Malvek has no server and no
account, so there is nothing to restore it from, and that is on purpose.
Log in to the server another way, delete the old phone's line from
~/.ssh/authorized_keys, then generate a new key on the new
phone and add it. For a server you can't afford to be locked out of, keep
a second way in: another device's key, or the provider's web console.
~/.ssh is 700 and
authorized_keys is 600, that both belong to
your user, and that the whole key is on a single line.nano
~/.ssh/authorized_keys and join it back into one line.