# Import hosts and snippets

> Bring your hosts and their keys from OpenSSH's configuration, PuTTY, a CSV file or Royal TS, and snippets from a CSV file.

Bring your hosts from another SSH client: OpenSSH's configuration, PuTTY, a CSV file (Termius' import template or another manager's export) or a Royal TS document. MorphGate shows what it found first, and you pick the hosts to import. The keys they sign in with are copied into your vault, so they work on every device your vault syncs to. The file you import from isn't changed.

Importing hosts works in the desktop app. Snippets can be imported from a CSV file on phones and tablets too.

## Import hosts

1. Choose **Hosts** at the top of the sidebar, then **Import…**.
2. Pick where the hosts come from: **OpenSSH**, **PuTTY**, **CSV** or **Royal TS**. MorphGate reads `~/.ssh/config` straight away, and for PuTTY the sessions saved on this computer.
3. To read another file, type its path and choose **Read**, or choose **Choose…** to pick it.
4. Check the list, and untick the hosts you don't want. **All** and **None** tick or untick every host. Hosts already in your vault start unticked.
5. If a key under **Keys** is encrypted, enter its passphrase. Leave it empty and the hosts that use it sign in another way (see below).
6. If you can write to more than one vault, pick the **Vault**. Then choose **Import** (for example **Import 3 hosts**).

MorphGate says what it imported, for example "Imported 3 hosts and 1 key.", and lists anything that didn't go as in the other client. The list is read again, so the hosts you imported now show **in the vault**.

## What the list shows

- **Each host**: Its label, how it signs in (a key, an SSH agent, a saved password, or a password asked each time), its group, whether it forwards the agent, and **in the vault** when one of your vaults has a host with the same address, port and user. Below: the user, address and port, and the jump hosts it goes through.
- **Connects by running on this computer**: The host's proxy command, from OpenSSH's configuration. Read it before you import: see [Jump hosts](https://morphgate.com/docs/jump-hosts.md).
- **Not imported**: What the other client does for this host that MorphGate leaves out, such as a port forward.
- **Keys**: The key files the ticked hosts sign in with, and what happens to each: **Copied into the vault**, **The vault has this key: the hosts use that one**, **Encrypted** (with a **Passphrase** field), or why it can't be read. A key with a certificate shows who the certificate signs in as and how long it's valid.
- **Warnings**: What the source holds that isn't imported at all, such as Telnet sessions.

## What comes in

- **Jump hosts** that the hosts you picked go through come along, even if you didn't tick them. A chain of jump hosts that goes round in a loop is dropped, and the result says so.
- **Keys** are copied into the vault, named after their file. A key your vault already has is used as it is. PuTTY `.ppk` keys are kept as OpenSSH keys. A key's certificate comes along: the one the configuration names, or the `-cert.pub` file next to the key.
- A key that can't be read, or an encrypted key you gave no passphrase for, stays behind. Its hosts sign in with the SSH agent where there is one (always on Windows), or ask for a password when they connect.
- **Groups** are matched by name: a group your vault has is used, otherwise a new one is made.
- **Tags and notes** come along. What wasn't imported is added to the host's notes, for example "From PuTTY, not imported: X11 forwarding".
- **Passwords** come in only from a CSV file's password column, and are saved in the vault.
- A host that the vault you import into already has, with the same address, port and user, isn't imported again and isn't changed. If another host goes through it, it's used as that jump host.
- Imported hosts have no VPN, terminal scheme or identity. Set those in the host's editor, or put the hosts in a group. See [Hosts, groups and identities](https://morphgate.com/docs/hosts.md).

## From OpenSSH

MorphGate reads `~/.ssh/config`, or the file you type, together with the files it includes. Each `Host` becomes a host, named after its alias. Lines like `Host *` are defaults for the others, not hosts.

- **`HostName`, `Port`, `User`**: The address, the port (22 without one) and the user (your user name on this computer without one).
- **`IdentityFile`**: The first file that exists is the host's key. If that file is a public key, the key lives in an SSH agent: the host signs in with the agent and offers only that key. Without an `IdentityFile`, MorphGate takes `id_ed25519`, `id_ecdsa` or `id_rsa` from `~/.ssh`, then the SSH agent, then a password.
- **`IdentityAgent`**: The agent the host signs in with. The 1Password, Bitwarden and Secretive agents are recognized by name, so the host works on each device that runs them. Another socket is kept as **Other socket or pipe**. `none` means no agent. See [Keys in 1Password, Bitwarden and other SSH agents](https://morphgate.com/docs/ssh-agents.md).
- **`ProxyJump`**: The host's jump hosts, chains included. A hop that names another `Host` is that host; a hop like `ops@bastion.example.com:2222` becomes a host of its own.
- **`ProxyCommand`**: The host's proxy command. Importing it allows it on this computer, since it came from this computer's own configuration and you saw it first. Your other devices ask before they run it.
- **`ForwardAgent`, `CertificateFile`**: **Forward the SSH agent**, and the key's certificate.

Not imported: `LocalForward`, `RemoteForward`, `DynamicForward` and `RemoteCommand`, listed under each host. `Match` blocks are skipped, and the list says so.

## From PuTTY

On Windows, MorphGate reads the sessions PuTTY saved on this computer. On Linux and macOS it reads `~/.putty/sessions` or `~/.config/putty/sessions`. You can also choose a `.reg` file exported from PuTTY on Windows, or type the path of a sessions folder.

- Each SSH session becomes a host named after the session, with its host name, port and user name. PuTTY's "Default Settings" is skipped. Telnet, Rlogin, serial and raw sessions aren't imported, and the list names them.
- The session's private key file (`.ppk`) is copied into the vault as an OpenSSH key.
- A session without a key signs in with Pageant if it's running (Windows), or asks for a password when it connects. PuTTY doesn't save passwords.
- Agent forwarding comes along as **Forward the SSH agent**.
- A session that goes through an SSH proxy gets that proxy as its jump host: the saved session of that name, or a new host.
- Not imported: other proxy types (SOCKS, HTTP, Telnet, a local command), port forwardings, X11 forwarding and remote commands.

## From a CSV file

Termius' import template has the columns `Groups,Label,Tags,Hostname/IP,Protocol,Port,Username,Password`. Other managers' exports work too: MorphGate finds the columns by their headers, in any order, separated by commas, semicolons or tabs. Only a column for the host is required.

- **Host**: A header like `Hostname/IP`, `Hostname`, `Host`, `Address`, `IP` or `Server`. Without one, MorphGate says "the file has no column for the host". A user and port written in the address (`ops@db1:2222`) count too.
- **Label, Group, Tags, Notes**: `Label` or `Name` (the address when empty); `Groups`, `Group` or `Folder`; `Tags`, separated by commas or semicolons; `Notes`, `Description` or `Comment`.
- **Port, User**: `Port` (22 when empty, or when it isn't a number, which the list says); `Username`, `User` or `Login`.
- **Password**: Saved in the vault with the host.
- **Key, Passphrase**: The path of a private key file on this computer (`Key`, `Private key`, `Identity file`), and its `Passphrase`. A key wins over a password.
- **Protocol**: Rows for SSH are imported; Mosh rows come in as SSH. Other protocols aren't imported, and the list names them.

## From Royal TS

Choose a Royal TS or Royal TSX document (`.rtsz` or `.rtsx`). A document saved with full encryption can't be read; save a copy without it in Royal TS first.

- SSH connections, and terminal connections of the SSH type, become hosts with their name, address and port. Templates are skipped. Other connections (Remote Desktop, VNC, web pages and so on) aren't imported, and the list counts them.
- The folders a connection is in become one group, such as `Production / Web`.
- The user and private key file come from the connection's credentials: its own, its folder's, or a saved credential it names.
- Passwords stay in Royal TS, which keeps them encrypted. Those hosts ask for their password when they connect.
- The description becomes the host's notes, and agent forwarding comes along.
- Not imported: proxies and X11 forwarding.

## Import snippets from a CSV file

1. Choose **Snippets** at the top of the sidebar, then **Import…**. On a phone, open the snippets and choose **Import from a CSV file…** under the list.
2. Choose the file. Not sure of the format? **Download an example** saves `morphgate-snippets-example.csv` in your Downloads folder (in the Files app, under MorphGate, on iPhone and iPad), to open in a spreadsheet or to pick right away.
3. Untick the snippets you don't want, pick the **Vault** if you have more than one, and choose **Import** (for example **Import 5 snippets**).

The file's first line names the columns: `Name`, `Command` and `Tags`, in any order. Then each line is a snippet.

- Only `Command` is required. Without it, MorphGate says the file "has no Command column".
- A command of several lines is one quoted value, as spreadsheets save it.
- A snippet without a name is named after the first line of its command.
- Tags are separated by commas or semicolons, in one value.
- Lines without a command are left out, and MorphGate says which.
- A snippet with the same name as one in the vault you import into starts unticked. If you tick it, it replaces the vault's, and the result says how many were replaced.

## Limits

- Importing hosts is in the desktop app only. Phones and tablets don't have **Import…** on the Hosts page.
- Not imported from any source: port forwards (save them as [tunnels](https://morphgate.com/docs/port-forwarding.md)), remote commands (a host can have a login command instead), X11 forwarding, proxies other than SSH jump hosts and OpenSSH's `ProxyCommand`, and Royal TS passwords. A CSV file can't describe jump hosts.
- An import never updates a host you already have. To bring in a changed host, edit it, or delete it and import it again.
