Pergunta

I did ssh-add. During the session it works fine, but when I exit and reconnect to the server with ssh it does not work anymore ssh-add -l says: no identities.

I do start the ssh-agent in my .bash_profile using eval $(ssh-agent).

Any ideas what I can do to keep the identities?

// EDIT So here is my scenario. I am connecting to my web-space using ssh. I want to pull data from github using git pull. I added the connection to github and git pull works fine. But it asks for the passphrase. Doing a ssh-add adn adding the passphrase stops that, but only for the current session.

I have to start the ssh-agent using something like eval $(ssh-agent) because it does not autostart on the server.

The main problem I am having is, that I need a script to do the git pull which is invoked by a request from github, so I can not give it the passphrase.

Foi útil?

Solução

If you're spawning the agent when your session starts, then it'll die when you disconnect. You could connect to a screen or byobu/tmux server which keeps the agent alive (you can skip an instance of bash if you connect like ssh user@hostname -t 'byobu').

Otherwise, have the agent come up when the machine boots so your session comings and goings don't affect it.

Edit: you can also forward your agent from your local machine. This works very well if you happen to have the same keys available on both machines. Try something like this in your ~/.ssh/config:

Host whatever
    Hostname        whatever.com
    User            username
    ForwardAgent    yes

You invoke this with ssh whatever, in case you are not familiar with that config file.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top