SSH Config Import
This content is for the 1.0.0 version. Switch to the latest version for up-to-date documentation.
PocketCmd can create servers from the Host entries in an ~/.ssh/config, together with the private keys they reference. There are two ways to import:
- From a computer with the one-shot
pcmd synccommand, scanned from Add Server › Import from Computer. - From a saved SSH server with Import SSH configs in its server sheet, which reads the config stored on that server.
Both work on Free. Free keeps one active server, so when an import brings in more, everything you selected is still imported: the extra servers arrive locked, and the app asks which server stays active. See Free and Pro.
From a computer: pcmd sync
Section titled “From a computer: pcmd sync”This needs the pcmd binary from PocketCmd Server on the computer that holds your SSH config. It does not need a running or paired server.
-
On the computer, run:
Terminal window pcmd syncIt starts a temporary server on a random free port and prints a QR code and a
pocketcmd://ssh-sync?…link. Over an SSH session the QR code is drawn in plain ASCII. -
In the app, open Add Server › Import from Computer, then Scan QR Code or Paste URL. Opening the link on the device works too; the app first asks you to confirm the computer’s details.
-
Select the hosts to import and enter the passphrase of any encrypted key.
The command exits after the first successful fetch, or after 60 seconds (--timeout 2m gives you longer). It runs against a throwaway state directory, so it creates no users or devices on that computer and leaves nothing running. The export is recorded in ~/.pocketcmd/audit.log on that computer. The connection is mutual TLS, pinned to the certificate fingerprint carried in the QR code. Phone and computer must reach each other on the network; on a machine with several interfaces, pick the address with --advertise-ip.
pcmd sync reads ~/.ssh/config the way ssh does. It follows Include lines (wildcards allowed, relative paths resolved against ~/.ssh), matches Host patterns with *, ? and !, and keeps the first value it finds for each setting, so a Host * block at the end fills in whatever a host left unset. Match blocks are skipped.
| Directive | Becomes |
|---|---|
Host |
One server per alias. Patterns with * or ? only supply settings to the aliases they match |
HostName |
Address. Without one, the alias itself, as ssh would connect |
User |
Username. Without one, the user running pcmd sync, as ssh would use |
Port |
Port, 22 if absent |
IdentityFile |
The first listed key file that exists, read from disk and sent with the host. ~ and the %d, %u, %h, %n, %r and %p tokens are expanded |
Every other directive is ignored.
From a saved SSH server
Section titled “From a saved SSH server”If your ~/.ssh/config lives on a server you have already added, open that server’s sheet, tap ⋮ and choose Import SSH configs. The option appears for SSH servers.
- PocketCmd connects over SSH and reads
~/.ssh/configon the server, followingIncludelines. - It resolves each host with
ssh -Gon the server, soHost *defaults and other matching blocks apply the way the server’s ownsshwould apply them. Hosts with wildcard names are skipped. - Select the hosts to import.
- PocketCmd reads the referenced key files from the server and asks for the passphrase of any encrypted key.
- For hosts without a usable key, Passwords (optional) lets you enter a password. Leave a field empty to skip it.
This method imports the host name, HostName, Port, User and the first IdentityFile that exists on the server. The server needs the OpenSSH client installed for ssh -G.
What happens on import
Section titled “What happens on import”- Each selected host becomes an SSH server. A host with a key uses key authentication; the others use password authentication.
- A host whose address, port and username match an SSH server you already have is skipped, and the summary counts it as skipped.
- Keys are stored in your key list and linked to their servers. A key that is already stored, byte for byte, is reused.
- Keys and passwords are encrypted with your vault key before they are stored.
- An older PocketCmd Server can send a host without a username. That host is imported without one and listed as
?@host; set the username in its server form before you connect.
Directives such as ProxyJump, LocalForward, RemoteForward and ForwardAgent are not imported. Set up jump hosts, port forwarding and agent forwarding on the server afterwards.
Importing a key file by hand
Section titled “Importing a key file by hand”To add a key without a config, open Settings › Connection › SSH Keys, add a key and choose Import existing key. See Key Management and Supported Key Formats.