>_ Malvek

How to generate an SSH key on your iPhone and add it to a server

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.

How it works, in one paragraph

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.

What you need

1. Generate the key

  1. Open the Keys tab and tap Generate key (or the + button if you already have keys).
  2. Give it a name you'll recognise later, such as iPhone or Home Lab, and tap Generate.

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

2. Add the public key to the server

Pick whichever of these fits your server.

Option A: you can log in with a password

  1. Tap Copy on the public key.
  2. Connect to the server with your password and open a terminal.
  3. Run these commands, pasting the key between the quotes:
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.

Option B: your hosting provider has an SSH keys page

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.

Option C: someone else manages the server

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.

3. Tell the app to use the key

  1. Long-press the host and choose Edit host, or add a new host.
  2. Under the login method, choose Private key.
  3. Tap Saved key, pick the key you generated, and tap Save.
  4. Tap the host. It should connect without asking for a password.

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.

Already have a key? Import it instead

If you'd rather use the key from your laptop, open the Keys tab and tap the import button in the top bar.

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.

If you lose the phone

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.

Troubleshooting

Get Malvek on the App Store File transfer guide Raspberry Pi guide