apache - Moving a file from a remote server using CGI script -
this need
i have local server hosting cgi shell scripts. have file in remote server. want cgi script copy file remote server local server.
this tried
to avoid entering password every time, created key file using ssh-keygen command , copied public key file remote server /root/.ssh/authorised_keys file , worked. whenever execute scp user@remotehost:/root/ . intended file copied local server without manual authentication , works perfect.
now, want same thing apache user triggeres cgi script. used below command generate key file apache user
sudo -u _apache ssh-keygen -t rsa
and system response
enter file in save key (/library/webserver/.ssh/id_rsa)
normally .ssh keys stored in location /root/.ssh , why system command defaulting /library/webserver ? can have 2 .ssh files?
is there other solution trying?
thank you
every user in system should have his/her own ~/.ssh directory.
when ssh runs, .ssh directory in user's home directory. can check user's home directory /etc/passwd or finger utilty. when reading /etc/passwd home directory second end. example:
postgres:x:106:115:postgresql administrator,,,:/var/lib/postgresql:/bin/bash
in case, home directory /var/lib/postgresql
to solve problem, if not going use ssh else, can copy id_rsa key first user .ssh directory of second user (changing user ownership , keeping file chmod go-rwx).
or can generate new key did, , append new .ssh/id_rsa remote .ssh/authorized_keys.
beware first method have 2 users sharing same rsa key, , please note should not have root user on remote machine having authorized key can used within cgi script. both securty risks. better create non-priviledged user on remote machine , use transfer file.
Comments
Post a Comment