It seems like i'm having a bit of a discrepancy between the behavior of ssh-agent for two accounts I have configured.
I wrote a simple monitoring script to check on the availability of some VMs we have running. I did all the testing and debugging with my main access account. In the process, I generated an SSH keypair, kicked off ssh-agent, and added the identity to the agent to allow for the script to ssh without the need for a password.
Now, I would like to run this script as a service account user. I created the service account, and to generate the keys temporarily set the login shell to /bin/bash. I generated my keys, removed the passphrase, and added the identity to the agent.
The discrepancy seems to be with how the shell connects to the agent. In my user account, I haven't had to restart the agent since I started testing (about two weeks). But, when I attempt to run the script under the service account, I seem to have to restart the agent each time, add the identity, and then perform the work.
Ideally I would like the agent to run indefinitely and have the service account reconnect to it automatically whenever the script runs so I don't need to manage processes within the script. I've looked at the configurations of each account and can't find any differences. Any insight would be greatly appreciated.
**Edit: I forgot to point out that the agent does continuously run, but shell processes for the service account do not seem to be utilizing it and a new one has to get started:
ovmmon 14043 0.0 0.0 53916 204 ? Ss May17 0:00 ssh-agent ovmmon 14952 0.0 0.0 53916 204 ? Ss May17 0:00 ssh-agent
ssh-agent bash
and thenssh-add ~/.ssh/admin
I generated my keys, removed the passphrase
- If you keys do not have a pass-phrase, then you really don't need an agent. Just setup an ssh config file under your service account with anIdentityFile
option specifying the path to the keys. If that still doesn't help, then login as the service account and try connecting to ssh with the-vv
option to get verbose output.ssh -i ~/.ssh/admin
(admin is the file I named when generating the key)