Public-Key Authentication

The OpenSSH clients--ssh, scp, and sftp--and the key-related programs--ssh-keygen, ssh-agent, and ssh-add (covered in Chapter 6)--use public-key authentication just as they do under Unix. You might need to know where your ~/.ssh folder is to refer to keys. [14.2]

When connecting to the Cygwin SSHD Service (sshd) from the outside world, there are a few things to think about:

  • Make sure your ~/.ssh/authorized_keys file contains the appropriate public keys. [6.1.1]

  • Check the Cygwin SSHD Service in the Services control panel, and note the NT user account under which it is running. Then make sure that this account:

    • Has read access to your ~/.ssh directory and your ~/.ssh/authorized_keys file.

    • Has read access to the host keys in the Cygwin /etc directory.

    • Has write access to the log file /var/log/sshd.log.

    • Is in the local Administrators group, if you plan to invoke operations by SSH that require administrative privileges. Then authenticate using this account. (For more flexible credentials, consider a PKI solution. [11.5] Cygwin includes a Kerberos package.[166])

    • Is listed in the Cygwin /etc/passwd file. Use the Cygwin mkpasswd program to generate this file if you need; for example, in the Cygwin shell:

          $ mkpasswd -l > /etc/passwd

      but make sure you understand what you’re doing so that you don’t wipe out vital accounts! Run man mkpasswd to learn more.

14.4.1 Running an Agent

An agent is a program that keeps private keys in memory and provides authentication services to SSH clients. If you preload an agent with private keys at the beginning of a login session, your SSH clients won’t prompt for passphrases. Instead, they communicate with the agent as needed. [2.5] The OpenSSH agent program is ssh-agent.

In order for ssh-agent to work, it communicates via environment variables. [6.3.2] If you’re using the Cygwin shell (bash), you can start the agent via the same methods as on Unix. Unfortunately, these methods don’t work immediately on Windows if you’re using the command shell (cmd.exe or command.exe), so here is a quick recipe:

  1. Run the agent:

        C:> ssh-agent
        SSH_AUTH_SOCK=/tmp/ssh-agent.1468; export SSH_AUTH_SOCK;
        SSH_AGENT_PID=3212; export SSH_AGENT_PID;
        echo Agent pid 3212;
  2. Notice the output includes some environment variables:

        SSH_AUTH_SOCK=/tmp/ssh-agent.1468; export SSH_AUTH_SOCK;
        SSH_AGENT_PID=3212; export SSH_AGENT_PID;
  3. Set the environment variables by hand:

        C:> set SSH_AUTH_SOCK=/tmp/ssh-agent.1468
        C:> set SSH_AGENT_PID=3212
  4. Your agent is ready to load with keys: [2.5]

        C:> ssh-add
        Enter passphrase for /home/you/.ssh/id_dsa: ********
        Identity added: /home/you/.ssh/id_dsa (/home/you/.ssh/id_dsa)


[166] For Kerberos or GSSAPI support., you might need to recompile OpenSSH. At press time, KerberosAuthentication and GSSAPIAuthentication are disabled in the Cygwin binaries for OpenSSH. You’ll need to download the OpenSSH source code and recompile it with the GNU C compiler, gcc, also included with Cygwin. Once things are set up, they do work as in our case study. [11.5.2]

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.171.121