# Problem with ssh-key / post receive

**URL:** <https://forum.gitea.com/t/problem-with-ssh-key-post-receive/59>\
**Category:** Install/Maintain/Configure\
**Created:** [August 21, 2017, 4:00pm UTC](https://forum.gitea.com/t/problem-with-ssh-key-post-receive/59 "2017-08-21T16:00:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirgendswo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/nirgendswo/32/4710_2.png) [@nirgendswo](https://forum.gitea.com/u/nirgendswo)\
**Post date:** [August 21, 2017, 4:00pm UTC](https://forum.gitea.com/t/problem-with-ssh-key-post-receive/59/1 "2017-08-21T16:00:30Z")

</div>

Hello,

i’m using [deployer](http://deployer.org) on the Server with gitea. The Idea is, a post-receive calls the deployer for the repo. On the console with the gitea-user the deployer runs, no errors. All ssh-keys are added to the ssh-agent and he is loaded from a script in the .bash\_profile. The post receive runs with the same user, but if i push, i get this,

```auto
remote: [Deployer\Exception\RuntimeException]    
remote: The command "echo $0" failed.            
remote: Exit Code: -1 (Unknown error)            
remote: Host Name: release                       
remote: ================                         
remote: Permission denied, please try again.     
remote: Permission denied, please try again.     
remote: Permission denied (publickey,password).  

```

---

<div class="post-metadata">

**Author:** ![lunny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/lunny/32/4701_2.png) [@lunny](https://forum.gitea.com/u/lunny)\
**Post date:** [August 23, 2017, 1:38am UTC](https://forum.gitea.com/t/problem-with-ssh-key-post-receive/59/2 "2017-08-23T01:38:07Z")

</div>

Coud you post your post-receive script here? Cannot find the reason.

---

<div class="post-metadata">

**Author:** ![nirgendswo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/nirgendswo/32/4710_2.png) [@nirgendswo](https://forum.gitea.com/u/nirgendswo)\
**Post date:** [August 23, 2017, 8:05am UTC](https://forum.gitea.com/t/problem-with-ssh-key-post-receive/59/3 "2017-08-23T08:05:49Z")

</div>

Damn! 😃

There only two lines in my post-receive, he only starts the deployer. But i found the reason. I have add the keys to ssh-agent. The ssh-agent starts with a script in the ./bash\_profile. BUT i have checked the post-receive, there is no ssh-agent running, so he didn’t know the keys… I’m not sure how to “fetch” the ssh-agent 😕

---

<div class="post-metadata">

**Author:** ![nirgendswo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/nirgendswo/32/4710_2.png) [@nirgendswo](https://forum.gitea.com/u/nirgendswo)\
**Post date:** [August 31, 2017, 9:46am UTC](https://forum.gitea.com/t/problem-with-ssh-key-post-receive/59/4 "2017-08-31T09:46:28Z")

</div>

Finally, i found a solution, with this posting about the ssh-agent,

[http://rabexc.org/posts/pitfalls-of-ssh-agents](http://rabexc.org/posts/pitfalls-of-ssh-agents)

I run a script to get the ssh-agent that started with the bash. The Problem was the ssh-agent that was not running. It makes sense, because gitea runs as a Service.

But i’m not really satisfied with this, it feels a little bit hacky.

---

<div class="post-metadata">

**Author:** ![lunny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/lunny/32/4701_2.png) [@lunny](https://forum.gitea.com/u/lunny)\
**Post date:** [September 3, 2017, 2:37pm UTC](https://forum.gitea.com/t/problem-with-ssh-key-post-receive/59/5 "2017-09-03T14:37:00Z")

</div>

it’s a service start sequence problem? maybe you should let gitea depends on ssh-agent which I’m not familiar with.
