# Lab 2: Passwordless SSH Access from PC and Mobile to Raspberry Pi

Objective\
• Enable SSH key‑based authentication from both PC and mobile\
• Store multiple public keys inside the file\
• Apply correct permissions to the directory\
• Verify passwordless login from both devices

Environment\
• Raspberry Pi OS (user: your-username)\
• Windows PC with an SSH key pair\
• Mobile device using Termius\
• Raspberry Pi reachable via SSH at your-raspberry-ip

**1. Generate an SSH key on the PC**

Create a new SSH key pair on Windows:

`ssh-keygen -t ed25519 -C "your-device-name"`

The public key is located in:

`%USERPROFILE%\.ssh\id_ed25519.pub`

**2. Retrieve the SSH key from the mobile device (Termius)**

Termius automatically generates an SSH key pair.

To view the public key:

* Open Termius
* Go to **Settings → Keys**
* Select your key
* Copy the public key

**3. Add both public keys to the Raspberry Pi**

Connect to the Raspberry Pi (password allowed temporarily) and open:

`nano ~/.ssh/authorized_keys`

Paste:

* the PC public key
* the mobile public key

Save and exit.

<figure><img src="https://1797790075-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQoEnMXJFzYvDRTV19He%2Fuploads%2Fx1YOOxHhHgPEHT2Tgzvv%2Fasd.png?alt=media&#x26;token=8bd3649a-69c3-43f7-bd24-c7d2f1b34a31" alt=""><figcaption></figcaption></figure>

**4. Set correct permissions**

Ensure the `.ssh` directory and the `authorized_keys` file have the proper permissions:

* `.ssh` directory → `700`
* `authorized_keys` file → `600`
* Owner → `your-username`

**5. Test passwordless access**

**From the PC**

Run:

`ssh your-username@your-raspberry-ip`

The login should complete without asking for a password.

**From the mobile device (Termius)**

Open the saved connection and verify that it logs in automatically.
