Introduction
In this project, you will learn how to configure an SSH certificate for the labex user, so that the labex user does not need to enter a password when SSH logging into the local experimental environment.
👀 Preview
## No password required to log into localhost
## Log in directly to enter a new shell
🎯 Tasks
In this project, you will learn:
- How to create a
.sshdirectory in thelabexuser's home directory - How to generate a new SSH key pair
- How to add the newly generated public key to the
authorized_keysfile - How to restart the SSH service after configuring the SSH certificate
- How to test the SSH connection without a password
🏆 Achievements
After completing this project, you will be able to:
- Securely log in to the local experimental environment using SSH certificates
- Manage the SSH configuration for the
labexuser - Understand the importance of using SSH certificates for secure access to servers
Create SSH Directory and Generate SSH Key Pair
In this step, you will learn how to create a .ssh directory in the labex user's home directory and generate a new SSH key pair.
Open a terminal and log in as the
labexuser:sudo su - labexCreate the
.sshdirectory:mkdir -p ~/.sshGenerate a new SSH key pair:
ssh-keygen -t rsa -b 4096 -C "labex@localhost"When prompted, press Enter to accept the default file location and leave the passphrase empty.
Add Public Key to authorized_keys
In this step, you will learn how to add the newly generated public key to the authorized_keys file.
Append the public key to the
authorized_keysfile:cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keysSet the correct permissions for the
authorized_keysfile:chmod 600 ~/.ssh/authorized_keysRestart the SSH service:
sudo service ssh restart
Test the SSH Connection
In this step, you will learn how to test the SSH connection without a password.
Try to log in to the local experimental environment using the
labexuser:ssh labex@localhostYou should now be able to log in without a password.
Once logged in, you can explore the
labexuser's home directory:lsYou should see the
Code,Desktop,golang, andprojectdirectories.
Summary
Congratulations! You have completed this project. You can practice more labs in LabEx to improve your skills.



