A
A
Andrew2018-05-29 13:48:29
linux
Andrew, 2018-05-29 13:48:29

Where is it more correct to run ssh-agent?

Guys, tell me, pls. Where is it more correct to start ssh-agent and how to add the necessary key to the system during its startup. I add this script:

#start-ssh
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/mykey

Added here to these files:
.profile - does not work and knocks out an error on the login window to the system;
.bash_profile - doesn't work and doesn't throw an error;
.bashrc - works, but throws an error on the login window.
System: Ubuntu 18.04
PS on 16.04 - used the keychain utility and everything worked fine, on 18.04 - it doesn't work for me either.
Where would be the right place to add this script? If I wrote it wrong, tell me how I can improve it, thanks.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2018-05-30
@Viji

Why add the key each time at system startup... generate once and it will be added to /home/user/.ssh/
And ssh agent starts automatically...
ps -ef | grep ssh

A
Andrew, 2018-05-30
@Inexorable

Solved my issue in .ssh/config you need to write
Host github.com (or other)
IdentityFile ~/.ssh/your_key_name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question