0

In my web application (Apache httpd) at Centos 7, I'm making an SSH connection with forward agent

example:

ssh -A $user@$proxyIP $user@DestinationIP ls -l

if I want it to run in the terminal of Apache user, i got pass that commands:

ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-zDrTcmfTt6W6/agent.5034; export SSH_AUTH_SOCK;
SSH_AGENT_PID=5035; export SSH_AGENT_PID;
ssh-add /usr/share/httpd/.ssh/id_rsa

and after this action, using the private key, I can connect to the destination host through terminal. Problem starts, when i try to make connection using website. Bash script(triggered by website code) do not set environment variables SSH_AUTH and SSH_AGENT_PID declared in it, so i get announcment:

Permission denied, please try again. Received disconnect from $DestinationIP port 22:2: Too many authentication

i tried to add envs permanently by pasting it to

/usr/share/httpd/.profile

but such action works for normal user (/home/$user/.profile), but not for apache user.

the second attempt was to add this code to

/etc/sysconfig/httpd

but after restart apache, it doesnt work too.

0 Answers0