Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
    • Security
Google Cloud Platform icon
Labs

Generating and Exchanging SSH Keys Between Servers

You have been tasked with finding a way to make some scripts work between servers, without having to store passwords in the script files. You have discovered that one way to do this is by creating a trust relationship between servers by sharing SSH keys between the servers. In this hands-on lab, we will generate SSH keys for two servers and exchange the keys in order to establish a trust relationship between them.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
Sep 19, 2025
Duration
1h 0m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Generate a Key Pair on Client1
    1. Generate a key pair (id_rsa.pub and id_rsa) on Client1 (10.0.1.11):
    ssh-keygen -t rsa
    
  2. Challenge

    Authorize Client1 to Trust Itself
    1. Run the following command on Client1:
    cat /home/cloud_user/.ssh/id_rsa.pub >> /home/cloud_user/.ssh/authorized_keys
    
    1. Verify that the authorization was successful.
    ssh [email protected]
    
  3. Challenge

    Copy the SSH Key to Server1
    1. From Client1, retrieve the hostname of Server1.
    ssh 10.0.1.10 hostname 
    
    1. You should be prompted for the cloud_user password.
    2. Copy the SSH keys to Server1 to establish trust between the two devices.
    scp -r /home/cloud_user/.ssh* 10.0.1.10:/home/cloud_user/
    
    **Note:** In a real environment, using secure copy (`scp`) is not best practice, as the private key should not be shared with multiple servers. In your own environment, I recommend using the `ssh-copy-id` command to only copy the public key, as that's all that's needed. But for the purposes of this lab, we'll use the above command.
    
    1. Verify that the trust relationship has been established.
    ssh 10.0.1.10 hostname
    
    1. Run the following two commands on Server1 to verify that the trust relationship has been established:
    ssh 10.0.1.11 hostname
    hostname && ssh 10.0.1.11 hostname
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight