# SSH from Windows

You can connect from Windows in three ways. Use OpenSSH if you can: it is already installed on Windows 10 and later and works like the commands in the other guides. All three need an SSH key added in the console. See [Connect with SSH](/docs/connect-ssh).

## Option 1: OpenSSH in PowerShell

1. Open **PowerShell**.
2. Create a key if you do not have one:

```powershell
ssh-keygen -t ed25519 -C "you@example.com"
```

3. Show the public key and copy the whole line:

```powershell
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub
```

4. In the console go to **SSH keys**, select **Add key** and paste it. Choose the key when you deploy.
5. Open the server, select **Connect**, copy the command and paste it into PowerShell:

```powershell
ssh -i $env:USERPROFILE\.ssh\id_ed25519 root@HOST -p PORT
```

If Windows says the key file permissions are too open, only your own user may read the private key file. Right-click the file, choose **Properties**, then **Security**, and remove other users.

## Option 2: PuTTY

PuTTY uses its own key format.

1. Install PuTTY, which includes PuTTYgen.
2. Open **PuTTYgen**. Choose **Load** and select your private key file, or create a key with type **EdDSA** (Ed25519) and select **Generate**.
3. Copy the text in **Public key for pasting into OpenSSH authorized_keys file** and add it under **SSH keys** in the console.
4. Select **Save private key** to make a `.ppk` file. Keep it private and never paste it anywhere.
5. Open **PuTTY**. Under **Session** enter the **Host Name** and **Port** from the **Connect** tab, with connection type **SSH**.
6. Under **Connection > SSH > Auth > Credentials** choose your `.ppk` file.
7. Under **Connection > Data** set **Auto-login username** to `root`.
8. Save the session and select **Open**. Accept the host key the first time.

## Option 3: VS Code Remote

1. Install **Visual Studio Code** and the **Remote - SSH** extension.
2. Press `F1`, run **Remote-SSH: Open SSH Configuration File** and choose `C:\Users\YOU\.ssh\config`.
3. Add the entry from the **Connect** tab (the **VS Code** help there has a copy button), for example:

```text
Host apidly-server
  HostName HOST
  Port PORT
  User root
  IdentityFile C:\Users\YOU\.ssh\id_ed25519
```

4. Press `F1`, run **Remote-SSH: Connect to Host** and choose `apidly-server`.
5. Open a folder such as `/workspace`. VS Code installs its helper on the server the first time, which needs a moment.

The host and port can change after a stop and start. Update the entry when they do.

## Copy files

PowerShell includes `scp`:

```powershell
scp -P PORT .\file.txt root@HOST:/workspace/
```

`rsync` is not included in Windows. Use `scp`, or use rsync inside Windows Subsystem for Linux. See [Moving files](/docs/moving-files).

## If it does not work

- **Permission denied:** the key you added is not the one being used. Add `-i` with the right path.
- **Connection timed out:** the server may be stopped or still starting, or the port changed. Copy the command again.
- **Host key changed warning:** a new server reused the address. Remove the old line from `C:\Users\YOU\.ssh\known_hosts` or run `ssh-keygen -R "[HOST]:PORT"`.

More in [Server problems](/docs/server-problems).
