Horje
How to check if ssh-agent is already running in bash Code Example
How to check if ssh-agent is already running in bash
PID_SSH_AGENT=`eval ssh-agent -s | grep -Po "(?<=pid\ ).*(?=\;)"`
How to check if ssh-agent is already running in bash
if [ $(ps ax | grep [s]sh-agent | wc -l) -gt 0 ] ; then
    echo "ssh-agent is already running"
else
    eval $(ssh-agent -s)
    if [ "$(ssh-add -l)" == "The agent has no identities." ] ; then
        ssh-add ~/.ssh/id_rsa
    fi

    # Don't leave extra agents around: kill it on exit. You may not want this part.
    trap "ssh-agent -k" exit
fi




Shell

Related
code to change the mac address kali linux Code Example code to change the mac address kali linux Code Example
bash for loop string Code Example bash for loop string Code Example
windows start service Code Example windows start service Code Example
ubuntu keeps freezing 20.04 Code Example ubuntu keeps freezing 20.04 Code Example
powershell pip install module Code Example powershell pip install module Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10