# Connecting to a remote server (SSH/FTP)

### Set up your remote server

Before using this feature, you'll need to set up a SSH (SFTP) or FTP server on your computer or server. On a Mac, you can do this by enabling Remote Login and full disk access in the `Sharing` section of System Preferences.

![Enabling SSH server on a Mac](/files/pfABW8Y47JhyPjPwILET)

### Set up a new remote in Code App

Open the remote section in the side bar and enter the server's information. Enable `Remember credentials` to save the credentials. Code App will ask for Face ID or Touch ID authentication when you connect to the server again in the future.

![Setting up a new remote](/files/CnqH9w0bJmV5i3Cdg3jf)

### Key Authentication

Besides password, SSH keys can also be used to authenticate your server. To do so, enable the `Use key authentication` option and enter your private key.&#x20;

#### Generating key-pairs in Code App

If you don't already have a key-pair, you can generate one with the `ssh-keygen` command in the terminal. You might need to specify the type of keys to generate depending on your server's configuration. For example on macOS Ventura, the default generated RSA key pair is not supported. You can generate a ed25519 key-pair instead by running `ssh-keygen -t ed25519`.

Then, copy the public key to your server's `authorized_keys` file. On macOS, it is located at `~/.ssh/authorized_keys.`

### Finishing up

Congratulations! You can now access the remote server's files and terminal.

{% hint style="info" %}
**Good to know:** Only SSH server allows terminal access
{% endhint %}

![](/files/7vszfZVrKEgZsyx3BnuX)

### Port forwarding (SSH Tunneling)

After successfully connecting to your remote server, you can set up port forwarding to access the server's application ports. A common usage is to access a web server hosted on the remote.

<figure><img src="/files/dV8lxxCW3WSUYtHN15t0" alt=""><figcaption><p>Accessing port 8100 on the remote server</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://code.thebaselab.com/guides/connecting-to-a-remote-server-ssh-ftp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
