Generating and Exchanging SSH Keys for Secure Access

15 minutes
  • 2 Learning Objectives

About this Hands-on Lab

Understanding the creation and exchange of SSH keys is a key concept to grasp as a new system administrator. In this lab, we will generate keys on two systems using the `ssh-keygen` utility and learn how to exchange and verify the keys with a remote system using `ssh-copy-id` and associated key files on each. At the end of this lab, you will understand how to create secure keys for remote access, how to exchange them, and where to store them on each system involved in the chain.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the SSH Keys on Server 1 and Server 2.
  1. Generate a new key on server 1.
    ssh-keygen
  2. Generate a new key on server 2.
    ssh-keygen
Exchange the Keys between Server 1 and Server 2.

The student will need to exchange the cloud_user service account keys created previously with the matching account to and from SERVER ONE and SERVER TWO.

  1. Copy the contents of id_rsa.pub to the clipboard.
  2. Connect to server 2.
  3. Append the public key to the authorized_keys file.
  4. Generate a new key on server 2.
  5. Copy the contents of the id_rsa.pub to the clipboard.
  6. Connect back to server 1.
  7. Append the public key to the authorized_keys file.

Additional Resources

The development team in your organization is setting up their new development servers in preparation for the creation of a new web-based API. They are going to be creating configurations, copying files, etc. between two servers using a single service account.

You have been provided with credentials and connectivity information to those two new server instances. The service account they wish to use is the cloud_user account that you were provided. Following company security policy, a complex password has been set that is making periodic connections, copies, and service configurations hard for the team. They have asked you to simplify the process and create a trust for the service account between the two systems.

To make the trust between the two systems, you have determined the easiest method for doing so while maintaining security would be to use SSH keys and exchange them between the systems. You will need to create keys on both servers for the cloud_user service account and then exchange each server's account key with the other. This will facilitate connections from one system to the other and the reverse, regardless of the initiating system. Once you verify each user can log in from one server to the other, you can turn them back over to your team for use.

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?