SOLVED load ssh-agent automatically for git private repos

Jul 24, 2018
17
3
3
Romania
cPanel Access Level
Website Owner
In my cPanel user files, I'm using a private BitBucket repository.
In order to connect to it, I have created an SSH public/private key pair using the cPanel user interface so I can use them as a way to connect to my remote repository.
The problem is that I wasn't able to connect to the remote repo usng ssh keys, so after I googled a lot, I found that my ssh-agent is not loaded so I used:

Code:
eval `ssh-agent -s`
ssh-add ~/.ssh/myCustomPrivateKey
Then it asks me the password for the private key and only after these I'm able to use my repository (push/pull..). And everytime I need to update my repo (ex. to pull the latest changes) I need to exececute those commands to start the ssh-agent and then to add the private key as an identity to it.

How can I skip this manual start of ssh-agent .. or in the end I just wanna use my repo through ssh keys.
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,634
2,629
363
cPanel Access Level
Root Administrator
Hey there! How about adding these to the bash profile or bashrc files for the user, such as what is outlined here?

 
  • Like
Reactions: Spidey Catalin
Jul 24, 2018
17
3
3
Romania
cPanel Access Level
Website Owner
Hey there! How about adding these to the bash profile or bashrc files for the user, such as what is outlined here?

You're right, it could be a way.. but I'm not very sure if this is the most efficient solution for what I'm trying to do..What do you think? is there another way to be able to connect to my remote repository ? Is there something that I'm missing ? Or using this ```ssh-agent``` is the only way?
Or maybe if I would create a new ssh key pair using the default name id_rsa without password protecting the private key, maybe the ssh-agent will load it automatically ?

Thanks for your suggestion
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,634
2,629
363
cPanel Access Level
Root Administrator
Thanks for the additional thoughts. I read through a few of the Bitbucket docs and they do use a key, so you'd need make the SSH connection happen with a key in some way. If you plan to use that user almost exclusively for the repo access, the automation I thought of might be the easiest way.
 
  • Like
Reactions: Spidey Catalin