16

I need to add a private SSH key to Putty Agent (pagent.exe) every time a Windows server starts up -- before a user logs on interactively. The key is to be used by a service.

If it was a regular user that needed to use the key, I would just place a shortcut in the Startup folder, however, this does not work on a server, because no user logs in.

I need this on Windows Server 2008 as well as Windows Server 2003.

I figure this must be a pretty common use case as public key authentication with SSH and SFTP becomes more widespread.

ervingsb
  • 395
  • 1
  • 6
  • 16

1 Answers1

21

You can provide a path to the key on the Target command line in the shortcut

  • Create a shortcut to put in startup.
  • Right click -> properties
  • Modify the Target: section to add the key

    C:\Program Files\putty\pageant.exe C:\Program Files\putty\keys\iain.ppk

When your system starts pageant will load the key and if it requires a pass phrase to unlock it it will ask for it.

You can add multiple keys on the pageant command line too e.g.

C:\Program Files\putty\pageant.exe C:\keys\iain.ppk c:\keys\user1.ppk
user9517
  • 115,471
  • 20
  • 215
  • 297
  • Will this work for servers on which users never logs in? – ervingsb Jan 03 '12 at 19:12
  • 1
    If the keys don't have a pass phrase then yes. If they do have a pass phrase then someone needs to supply it. – user9517 Jan 03 '12 at 19:53
  • Can you elaborate on this step: "Create a shortcut to put in startup." What startup folder do you mean here? Normally startup folders are related to a specific user and only run when said user logs in, right? – ervingsb Jan 04 '12 at 07:40
  • The lines above could just as easily be put in a batch file couldn't they? – user9517 Jan 04 '12 at 09:06
  • Sure, but how do I make sure that the bat file is run on server startup? Even when no users are logged in? – ervingsb Jan 04 '12 at 12:24
  • 2
    You could use the builtin "Task Scheduler" which allows you to execute programs at various times, for example system startup. – marc.guenther Feb 23 '12 at 12:08