# Connect to a server with SFTP

> Find your server's SFTP address and username, then connect with FileZilla, WinSCP or the sftp command.

Source: https://www.coritan.com/docs/managed-containers/sftp/

In the dashboard:

- /dashboard/servers/…/files: https://www.coritan.com/dashboard/servers

SFTP lets a desktop client such as FileZilla, WinSCP or Cyberduck, or the `sftp` command, read and write your server's files. Use it for whole folders and for files over 100 MB, which the [dashboard file manager](/docs/managed-containers/files/) cannot upload.

## Before you begin

- You need your Coritan account password. SFTP signs in with the same password as the dashboard.
- On a server someone shared with you, the owner must have given you the Files permission. You sign in with your own email address and password.
- The server must not be suspended.
- SFTP accepts a password only. It does not accept SSH keys, and it does not ask for a two-factor code.

## Find the connection details

1. In the [dashboard](https://www.coritan.com/dashboard/servers), go to **Container Apps** and open the server, then the **Files** tab.
2. On the **SFTP connection** card at the top, select **Show details**.
3. Copy each value with **Copy host**, **Copy port** and **Copy username**.

**Host**
: The address of the machine your server runs on. It is not always the address players join.

**Port**
: `2022`.

**Username**
: Your account email address, a full stop, then the first eight characters of the server's ID, for example `alex@example.com.1a2b3c4d`. Each server has its own username.

**Password**
: Your account password.

## Connect with a desktop client

1. In your SFTP client, start a new connection and choose the SFTP protocol. FTP and FTPS do not work.
2. Enter the host, port `2022`, username and password from the dashboard.
3. Connect. The first time, the client asks whether to trust the server's host key. Accept it.

## Connect from the command line

Pass the username with `-o User=`, because it contains an `@`:

```bash
sftp -P 2022 -o User=alex@example.com.1a2b3c4d <host>
```

Enter your account password when asked. Use `put` to upload, `get` to download, and `put -r` or `get -r` for a folder.

## Result

Your client shows the server's files, starting at the server root, the same files the **Files** tab shows. Changes you make over SFTP show on the **Files** tab straight away. Restart the server after you change its configuration.

## Troubleshooting

The client says the password or credentials are wrong
: SFTP gives the same answer for every refused sign-in, so check each of these. Copy the username from the dashboard: it must hold your full email address, with the `@`, then a full stop and the eight characters. Use your current account password. On a shared server, check that the owner gave you the Files permission. A suspended server, or one we locked during an abuse review, refuses every sign-in, and the server page shows a banner when either applies.

The username in the dashboard has no `@` in it
: The page could not load the connection details and shows a guess instead. Reload the page and copy the username again.

The client runs out of attempts before it asks for the password
: Your client offers every SSH key it has first, and each one counts as a failed attempt. Turn off key sign-in for this connection. With the `sftp` command, add `-o PreferredAuthentications=password`.

The connection times out or is refused
: Check that the port is `2022`, not `22`, and that the protocol is SFTP. A firewall on your network may block port 2022.

## Related

- [Manage server files](/docs/managed-containers/files/) in the dashboard.
- [Share a server with other users](/docs/managed-containers/users/) explains the Files permission.
- [Change or reset your password](/docs/account/password/) changes the password SFTP uses too.

## With the API

`GET /api/v1/client/servers/{uuid}/sftp` returns the connection details for your account on that server. It never returns a password, because the password is your account password.

```bash
curl https://api.coritan.com/api/v1/client/servers/$SERVER/sftp \
  -H "Authorization: Bearer $CORITAN_TOKEN"
```

```json
{"host": "<host>", "port": 2022, "username": "alex@example.com.1a2b3c4d"}
```

On a server shared with you, the route needs the `file.sftp` permission, which the Files permission in the dashboard includes.

## API

- `GET /api/v1/client/servers/{uuid}/sftp`: Connection details for this server's SFTP login (https://www.coritan.com/docs/api/reference/client/container-apps/servers/#op-get-api-v1-client-servers-uuid-sftp)
