delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/05/18/13:26:41

X-Spam-Check-By: sourceware.org
Message-ID: <BAY125-F4059F2BD981CF64282FE9EB5320@phx.gbl>
X-Sender: karlm30 AT hotmail DOT com
From: "Karl M" <karlm30 AT hotmail DOT com>
To: timb AT cdvinc DOT com, cygwin AT cygwin DOT com
Subject: Re: ssh-add cannot connect to authentication agent
Date: Fri, 18 May 2007 10:26:08 -0700
Mime-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

------=_NextPart_000_13d3_23f_2e60
Content-Type: text/plain; format=flowed

>From: Tim Beuman Subject: Re: ssh-add cannot connect to authentication 
>agent
>Date: Fri, 18 May 2007 09:11:00 -0700
>
>Haven't been able to nail it down that specific. I ended up modifying 
>ssh-agent to run as a service under the SYSTEM account rather than as a 
>background process under the user-account. It worked fine that way, even 
>with McAfee but like I said, it required a modification of ssh-agent 
>itself.
>
>Tim
>
Hi All...

I've been using ssh-agent as a service for years, with no modifications. I 
started doing it because keychain was slow to start up and lost the keys on 
logout, whereas ssh-agent as a service keeps the keys until a reboot.

Attached are two scripts secret-agent-service and 
secret-agent-service-install are the scripts used for running ssh-agent as a 
service (one for each user that wants it). The sendchenv makes sure that the 
environment variables are up to date (if the service starts after the user 
logs in...have to love Microsoft).

HTH,

...Karl

_________________________________________________________________
Like the way Microsoft Office Outlook works? You’ll love Windows Live 
Hotmail. 
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_outlook_0507

------=_NextPart_000_13d3_23f_2e60
Content-Type: text/plain; name="secret-agent-service"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="secret-agent-service"

#!/bin/bash
# Launch the ssh-agent from a service so it survives logoff.

# When the service stops, kill the ssh-agent.
trap "ssh-agent -k;
  exit 0" TERM

# Clean up old files that may be left behind after a crash.
#   The file permissions make this safe to do in a multi-user
#   environment, but "/tmp" must be local to this host.
rm -rf /tmp/ssh-*

# Launch the ssh-agent.
eval $(ssh-agent)

# Provide the ssh-agent socket ID via the registry and broadcast
#   the change in case the user is logged before we finish.
#   Do not provide the ssh-agent PID to minimize the risk of
#   accidentally killing the ssh-agent.
regtool -s set /HKEY_CURRENT_USER/Environment/SSH_AUTH_SOCK $SSH_AUTH_SOCK
regtool remove /HKEY_CURRENT_USER/Environment/SSH_AGENT_PID
sendchenv

# Wait quietly until the service is stopped.
while true; do
  sleep 24h &
  wait
done


------=_NextPart_000_13d3_23f_2e60
Content-Type: text/plain; name="secret-agent-service-install"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="secret-agent-service-install"

#!/bin/bash
# secret-agent-service-install service-name user-name

if [ "~$1" = "~" ]; then
  echo A service name is required.
  exit 1
fi

if [ "~$2" = "~" ]; then
  echo A user name is required.
  exit 1
fi

echo Uninstalling the secret-agent service, $1.
cygrunsrv --remove $1

echo Adding the \"Log on as a Service\" right for $2.
editrights -a SeServiceLogonRight -u $2

echo Installing the secret-agent service, $1.
cygrunsrv --install $1 \
  --args '/bin/secret-agent-service' \
  --disp "Secret Agent $2" \
  --desc "Creates an ssh-agent process for $2." \
  --path '/bin/bash' \
  --shutdown \
  --user "$2"

echo Starting the secret-agent service, $1.
cygrunsrv --start $1


------=_NextPart_000_13d3_23f_2e60
Content-Type: text/plain; name="sendchenv.c"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="sendchenv.c"

// Notify all windows that environment variables may have changed.

#include <windows.h>

int main()
{
  DWORD dwReturnValue;

  if (SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
      (LPARAM) "Environment", SMTO_ABORTIFHUNG, 5000, &dwReturnValue))
    return 0;
  else
    return 1;
}



------=_NextPart_000_13d3_23f_2e60
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------=_NextPart_000_13d3_23f_2e60--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019