how can I run the ssh-agent auto in the zsh environment?

LinuxDebianZshOh My-Zsh

Linux Problem Overview


I use the zsh and the oh-my-zsh. When I use the github and want to use the key to upload.

I always find the

#git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Because I have not add the key

#ssh-add -l
Could not open a connection to your authentication agent.

so I have to start the ssh-agent and add the key when I want to push or pull

#ssh-agent zsh
#ssh-add ~/.ssh/id_rsa

How can I add these command in the script,so I don't need type the commands?

Linux Solutions


Solution 1 - Linux

open .zshrc in a text editor:
vim ~/.zshrc

Add ssh-agent to the plugins list and save:

plugins=(git ssh-agent)

You may want to immediately reload your .zshrc settings:

source ~/.zshrc

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionwcc526View Question on Stackoverflow
Solution 1 - LinuxIlan FrumerView Answer on Stackoverflow