This document provides instructions for adding a generated SSH key to your GitHub account to enable secure code uploads for the AI Agent project.
If you need to generate a new key, you can use the following command (replace your_email@example.com):
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f ~/.ssh/ai_agent_github_rsaThis will create:
- Private Key Location:
~/.ssh/ai_agent_github_rsa - Public Key Location:
~/.ssh/ai_agent_github_rsa.pub
If you are using an existing key (e.g., ~/.ssh/github_rsa as previously generated), ensure you know its location.
- Copy your SSH public key. If you generated a new key as above, use:
If using an existing key, cat that public key file.
cat ~/.ssh/ai_agent_github_rsa.pub - Log in to your GitHub account.
- Click on your profile picture in the top-right corner and select "Settings".
- In the left sidebar, click on "SSH and GPG keys".
- Click the "New SSH key" or "Add SSH key" button.
- Enter a descriptive title for the key (e.g., "AI Agent Deploy Key" or "My Laptop Key").
- Paste the copied public key into the "Key" field.
- Click "Add SSH key" to save.
After adding the key to GitHub, you can test the connection (replace ~/.ssh/ai_agent_github_rsa with your actual private key path if different):
ssh -T git@github.com -i ~/.ssh/ai_agent_github_rsaYou should see a message like: "Hi username! You've successfully authenticated, but GitHub does not provide shell access."
To use this specific SSH key for Git operations with the /home/ubuntu/ai-agent project, you can:
-
Configure SSH Agent (Recommended for ease of use): Add your private key to the SSH agent:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/ai_agent_github_rsa # Or your specific private key
-
Configure
~/.ssh/configfile (Recommended for specific hosts/keys): Create or edit~/.ssh/configand add an entry for GitHub, specifying your key:Host github.com HostName github.com User git IdentityFile ~/.ssh/ai_agent_github_rsa # Path to your private key IdentitiesOnly yesWith this configuration, Git will automatically use the specified key for
github.com. -
Set Git remote URL to use SSH: Navigate to your local project directory
/home/ubuntu/ai-agent. If you've cloned using HTTPS, update the remote URL:cd /home/ubuntu/ai-agent git remote set-url origin git@github.com:username/repository-name.gitReplace
username/repository-name.gitwith your actual GitHub repository path. -
Specify key with
GIT_SSH_COMMAND(Less common for regular use): You can prefix your Git commands with this environment variable:GIT_SSH_COMMAND="ssh -i ~/.ssh/ai_agent_github_rsa" git clone git@github.com:username/repository.git GIT_SSH_COMMAND="ssh -i ~/.ssh/ai_agent_github_rsa" git push
By configuring SSH correctly, you can securely interact with your GitHub repository from the /home/ubuntu/ai-agent project directory.