If you want to persist the SSH agent and the added key across terminal sessions by using the `ssh-agent` service.
1. Open a terminal.
2. Run the following command to start the `ssh-agent` service:
eval "$(ssh-agent -s)"
3. Add your SSH key to the agent by running:
ssh-add ~/.ssh/id_ed25519
4. Next, create or modify the SSH configuration file by running:
nano ~/.ssh/config
5. Add key into Authorized keys:
cat .ssh/id_ed25519.pub >> .ssh/authorized_keys'
5. In the text editor, add the following lines to the file:
Host * AddKeysToAgent yes IdentityFile ~/.ssh/id_ed25519
This configuration enables the agent to automatically load the SSH key when needed.
6. Save the changes and exit the text editor (in nano, press Ctrl+X, then Y, then Enter).
From now on, whenever you start a new terminal session, the `ssh-agent` service should automatically be running, and your SSH key should be loaded into the agent. You won’t need to manually run `eval “$(ssh-agent -s)”` and `ssh-add` each time.
Note: This method assumes you’re using the OpenSSH client. If you’re using a different SSH client, the steps may vary.
https://github.com/appleboy/ssh-action#setting-up-ssh-key
Related posts:
- Setting Up SSH Connection between Ubuntu 22 and GitHub: A Step-by-Step Guide
- To check out to a specific commit in Git
- Tip for Let’s Encrypt Certificate Renewal with AWS EC2 and Security Groups
- from scratch and explain the process of configuring Apache to allow or deny the use of .htaccess files in detail.