# SSH Keys

Source: https://flywp.com/docs/server/ssh-keys/

SSH keys are cryptographic keys used to authenticate users to servers, offering a more secure method than traditional passwords. By leveraging both a public and a private key, SSH keys ensure secure, encrypted communication between the server and the client.

#### Table of Contents

1. [Public Key vs. Private Key](#public-key-vs-private-key)
2. [Advantages of Using SSH Keys Over Passwords](#advantages-of-using-ssh-keys-over-passwords)
3. [Adding SSH Keys in FlyWP](#adding-ssh-keys-in-flywp)
4. [Team SSH Keys in FlyWP](#team-ssh-keys-in-flywp)
5. [How to Obtain the Public SSH Key](#how-to-obtain-the-public-ssh-key)
6. [Adding SSH Keys in FlyWP](#adding-ssh-keys-in-flywp)
7. [How to Log in to the Server using SSH](#how-to-log-in-to-the-server-using-ssh)

[Video: How to Configure SSH Keys in Your Server with FlyWP | Step-by-Step Guide](https://www.youtube.com/watch?v=zIIPaFmz1wk)

## Public Key vs. Private Key

- **Public Key**: As the name suggests, this key is public and can be shared. It is placed on the server and used to lock the data that only the private key can unlock.
- **Private Key**: This key remains confidential and resides on the client’s machine. It’s used to unlock data encrypted by the public key. Under no circumstances should the private key be shared or exposed.

The combination of the private key and the public key enables secure communication by ensuring that the client holds the matching private key for the public key on the server.

## Advantages of Using SSH Keys Over Passwords

1. **Enhanced Security**: SSH keys provide a higher level of security compared to password-based logins. It’s virtually impossible for attackers to deduce the private key, even if they have the public key.
2. **Automation**: Systems and services can automate tasks like data transfers without needing to input passwords.
3. **Reduced Brute-Force Risk**: Since there’s no traditional password, the risk of brute-force attacks is significantly diminished.

## How to Obtain the Public SSH Key

Generating and accessing SSH keys varies depending on the operating system. Below are the methods for macOS, Windows, and Linux:

#### macOS & Linux:

1. **Generate SSH Key**: If you haven’t already generated an SSH key, you can do so using the following command in the terminal:   
     
   `ssh-keygen -t rsa -b 4096`
2. When prompted, press `Enter` to accept the default file location and name.
3. You’ll then be asked to enter a passphrase. You can either enter a passphrase or just press `Enter` to proceed without one.
4. **Access Public SSH Key**: To view your public key, use the `cat` command followed by the path to your public key. By default, the public key is saved in the `~/.ssh/` directory with the filename `id_rsa.pub`.   
     
   `cat ~/.ssh/id_rsa.pub`
5. Copy the displayed key to use it in FlyWP or any other application.

#### Windows:

**Using PuTTY**:

1. Download and install PuTTY and PuTTYgen from the [official website](https://www.putty.org/).
2. Open **PuTTYgen**.
3. Click the “Generate” button and follow the on-screen instructions.
4. Once generated, you’ll see your public key in the “Public key for pasting into OpenSSH authorized\_keys file” section.
5. Copy the public key to use it in FlyWP or any other application.

**Using Windows Subsystem for Linux (WSL)**:

If you have WSL installed, you can follow the macOS & Linux instructions above, as the process is identical.

Remember: Always keep your private key confidential. The public key, on the other hand, can be shared and is used to allow secure access to services that recognize your corresponding private key.

## Adding SSH Keys in FlyWP

In the FlyWP dashboard:

1. Navigate to your server.
2. Click on “SSH Keys” in the side menu.
3. Click “Add New Key” and input your public SSH key.
4. Provide a descriptive name for the key, making it easier to identify later.

[![](https://flywp.com/wp-content/uploads/2023/10/ssh-keys-page-server-1024x542.png)](https://flywp.com/wp-content/uploads/2023/10/ssh-keys-page-server.png)

### Team SSH Keys in FlyWP

For added convenience, FlyWP allows users to add SSH keys at the team level. Any SSH key added in the “Team Settings” section will automatically be integrated into every new server you create. This ensures that team members can securely access any new server without additional configuration steps.

[![](https://flywp.com/wp-content/uploads/2023/10/ssh-keys-page-team-1024x645.png)](https://flywp.com/wp-content/uploads/2023/10/ssh-keys-page-team.png)

## How to Log in to the Server using SSH

Once you have your SSH key set up, you can use it to log in to your server. The following are instructions based on the operating system:

#### macOS & Linux:

1. **Open Terminal**: Launch the Terminal application from your Applications folder or via a quick search.
2. **Login using SSH**: Use the `ssh` command along with your username and server’s IP address. The default username for FlyWP servers is `fly`.   
     
   `ssh fly@YOUR_SERVER_IP`   
     
   Replace `YOUR_SERVER_IP` with the actual IP address of your server.
3. If prompted about the authenticity of the host, type `yes` and press `Enter`.
4. If you set a passphrase for your SSH key, you might be prompted to enter it.

#### Windows:

**Using PuTTY**:

1. **Launch PuTTY**: Open PuTTY from your list of programs or from where you’ve saved the executable.
2. In the **Host Name (or IP address)** field, enter your server’s IP address.
3. In the **Port** field, ensure it’s set to `22` (default for SSH).
4. Navigate to `Connection` &gt; `SSH` &gt; `Auth` in the left sidebar.
5. Click the “Browse” button next to **Private key file for authentication** and select your private key (`id_rsa.ppk` if you used PuTTYgen).
6. Click the `Open` button.
7. A terminal window will pop up. When prompted for the username, enter `fly`.

Now you should be connected to your FlyWP server using SSH. Always ensure you’re operating in the correct directory and have the necessary permissions when making changes.

:::note
Always keep your private key confidential and ensure regular backups. If you believe your private key has been compromised, generate a new pair of SSH keys immediately and update them in FlyWP.
:::

## In this section

- [Whitelisting IP for SSH Connections](https://flywp.com/docs/server/ssh-keys/whitelisting-ip-for-ssh-connections.md): FlyWP users are required to whitelist the provided IP address on their hosting provider end. The IP address is 49.13.31.45, Configure on your hosting firewall.
- [FileZilla SSH Access](https://flywp.com/docs/server/ssh-keys/how-to-access-your-server-via-filezilla-using-ssh-keys.md)
