Is it possible to use ssh key which contents is specified in environment variable?

You want to use ssh-agent - this is an exact scenario for which it was designed.

ssh-agent provides authentication forwarding when you have used ssh to login to a remote server.

After configuring it, you can login to the remote server (using -A to forward the agent) and then do the git pull. It will forward the authentication request back to your local machine.


If you put your private key into environment variable it will not be much more secure. Note, that all environment variables are visible via /proc/$PID/environ. Use ssh-agent.