Using SSH keys
When you clone your project from a Git repository with SSH keys instead of a credential helper, you need to ensure that your local SSH agent is running.
If the SSH agent is running, you can add your local SSH keys to the agent using the ssh-add
command.
Check the following example:
However, you may receive an error on Linux and Windows since the SSH agent is not running by default on these systems.
To resolve such issues, use the following steps:
Ensure that you are running your local PowerShell as an administrator.
Enter the following command:
Set-Service ssh-agent -StartupType Automatic Start-Service ssh-agent Get-Service ssh-agent
Start the SSH agent with the following command:
eval "$(ssh-agent -s)"Add the following lines to
~/.bash_profile
or~/.zprofile
if you prefer to use theZsh
shell instead ofbash
.if [ -z "$SSH_AUTH_SOCK" ]; then # Check for a currently running instance of the agent RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`" if [ "$RUNNING_AGENT" = "0" ]; then # Launch a new instance of the agent ssh-agent -s > $HOME/.ssh/ssh-agent fi eval `cat $HOME/.ssh/ssh-agent` > /dev/null ssh-add $HOME/.ssh/<your ssh key> 2> /dev/null fiOn the last line of the suggested code, replace <your ssh key> with your specific ssh key. For example,
ssh-add $HOME/.ssh/id_ed344 2> /dev/null