Reputation: 1654
I want to deploy an app from my Mac to my ubutun 18.04 server. The problem is that when i go to my server and do a simple command like ssh -T [email protected] all work fine. It doesn't ask my passphrase etc... But when I run the command
ssh deploy@ipofmyserver 'ssh -T [email protected]'
I've got this error :
[email protected]: Permission denied (publickey).
My ssh key is generated and well inform in my bitbucket account.
I notice that when I connect with ssh deploy@... the user-agent is not started. When I run the command
ssh deploy@... 'eval `ssh-agent -s` && ssh-add && ssh -T [email protected]'
It ask me my passphrase and i've got the response that i'm able to connect. I try to use this solution to use a user-agent already running : https://github.com/wwalker/ssh-find-agent but it doesn't work.
Any solution ?
Upvotes: 0
Views: 339
Reputation: 1323203
I try to use this solution to use a user-agent already running : https://github.com/wwalker/ssh-find-agent but it doesn't work.
If, as documented, you tried to use . ssh-find-agent.sh
in ~/.bashrc
or ~./.zshrc
, that would not work.
The core of your issue (ssh inside ssh) is that the [ssh session would read:
~/.bash_profile
in an interactive session (not .bashrc
)ssh user@server 'a command'
)You should at least source your .bash
(rc
or _profile
) to trigger the . ssh-find-agent.sh
and see if it finds your ssh agent (already running, for which the passphrase was already entered)
If you have to enter a passphrase, you might need expect
as shown at the end of this answer.
The OP jean-max confirms in the comments that sourcing the .profile
(not .bash_profile
) is enough to make the . ssh-find-agent.sh
work.
chepner mentions in the comments the ssh -J
"jump host" option, here a dynamic one:
ssh -J deploy@ipfmyserver [email protected]
Upvotes: 1