I have a sample sh
script on my Linux environment, which basically run's the ssh-agent
for the current shell, adds a key to it and runs two git commands:
#!/bin/bash
eval "$(ssh-agent -s)"
ssh-add /home/duvdevan/.ssh/id_rsa
git -C /var/www/duvdevan/ reset --hard origin/master
git -C /var/www/duvdevan/ pull origin master
Script actually works fine, but every time I run it I get a new process so I think it might become a performance issue and I might end up having useless processes out there.
An example of the output:
Agent pid 12109
Identity added: /home/duvdevan/.ssh/custom_rsa (rsa w/o comment)
Also, along with all this, is it possible to find an existing ssh-agent
process and add my keys into it?
$SSH_AGENT_PID
. – chorobakill -9 $PID_SSH_AGENT
– alokssh-agent my-script
to start an agent that exits as soon asmy-script
exits. – chepner