Benches macOS

1

remote login and keychain

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I'm ssh'ing from my home machine into my OSX box at work.

On that machine, I have a bunch of passwords for ssh keys

stored in my login keychain that I use for accessing other machines.

If I'm sat in front of the machine, then,

provided that my login keychain is unlocked, I can access all

of the keys without having to type the individual passwords.

However, the same behavior doesn't happen when I ssh into the

machine from home - I'm asked for the password for each individual

ssh key when I try to use it, even if I've first run

security unlock-keychain <login.keychain>

How do I get ssh to read the appropriate ssh key password directly

from the keychain on the remote machine?

1 reply

Sign in or join Beachball Help to reply.

  1. 0

    Jun T.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    When you are sitting in front of the OSX box at work and logs into it, then ssh-agent is automatically started for you (to be more precise, it is started by launchd on demand). If you open a Terminal on the OSX box, then the environment variable SSH
    AUTHSOCK is already set (you can see this by typing "echo $SSH
    AUTHSOCK" or "env" in the terminal). When you ssh from the OSX box to a remote host, then the ssh client communicates with the ssh-agent through the socket, and the ssh-agent gets the pass phrase from the keychain; so you need not type the path phrase (assuming the keychain is already unlocked).

    When you are at home and ssh to the OSX box, then no ssh-agent is started on the OSX box automatically; if you type "echo $SSH
    AUTHSOCK" then you will get null response. So you must start an ssh-agent and set SSH
    AUTHSOCK by yourself. This can be done by running


    eval $(ssh-agent)

    after logging into the OSX box. Then by unlocking the keychain, you can ssh to the remote hosts without typing the pass phrase.