ForwardAgent в Jenkins

На самом деле я, вероятно, не использовал бы свой другой ответ в некоторых ситуациях, но я сохраню его там для ссылки.

Если бы Вашему коллеге дали их собственный VirtualHost, я установил бы это virtualhost для вывода их журналов к другому каталогу, так, чтобы они только видели ошибки для своей системы:

<VirtualHost *:80>
    ServerName colleagues.vhost.com
    DocumentRoot ...
    ...
    ErrorLog /home/user/errorlog-colleagues.vhost.com
</VirtualHost>

С другой стороны, если .htaccess файлы включены, заставляют их просто производить свои php журналы ошибок к местоположению, они хотят, например:

/path/to/webroot/.htaccess:

php_value error_log /home/user/phperrorlog-colleagues.vhost.com
6
задан 13 May 2013 в 19:36
1 ответ

I see this question has been unanswered for over a year, but here is how I solved the problem.

What you want to do is make sure that the user that runs jenkins

  1. checks to see if ssh-agent is running (if not, start it)
  2. checks to see if a key is loaded (if not, load one)

Put this in your ~/.bash_profile for the user that runs jenkins of the user that needs to forward agent, to ensure it runs with each new shell:

SSH_ENV="$HOME/.ssh/environment"

function start_agent {
  echo "Initializing new SSH agent..."
  /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
  echo succeeded
  chmod 600 "${SSH_ENV}"
  . "${SSH_ENV}" > /dev/null
  ssh-add .ssh/id_rsa
  cat .ssh/id_rsa.pub
}

#Source SSH Settings

if [ -f "${SSH_ENV}" ]
then
  . "${SSH_ENV}" > /dev/null
  ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || {
    start_agent;
  }
else
  start_agent;
fi

if [ `ssh-add -l | grep "The agent has no identities." | wc -l` == 1 ]
then
  ssh-add .ssh/id_rsa
  cat .ssh/id_rsa.pub
fi

About 50% of the code here I took from somewhere else but can't remember where to give credit. This should be fairly portable, and its use need not be limited to jenkins it should work in any ssh-agent forwarding situation.

1
ответ дан 3 December 2019 в 00:44

Теги

Похожие вопросы