Skip to content

Repository files navigation

macOS ssh-agent

This is a very simple user launch agent for ssh-agent.

This is typically useful if you are using a YubiKey, or otherwise want to use sk- keys, that the vanilla macOS ssh-agent does not support.

TL;DR

# Disable system agent
launchctl stop gui/501/com.openssh.ssh-agent
launchctl disable gui/501/com.openssh.ssh-agent
killall ssh-agent

# Install and start updated agent
brew install farcloser/brews/ssh-agent
brew services start ssh-agent

# Get the socket location in profile
printf '. "$HOME/.posh_ssh'"\n" >> ~/.profile
. ~/.profile

Installing without using brew services

Be sure to either have brew and the formula openssh installed, or alternatively that you do have a compatible ssh-agent in your PATH.

Git clone.

Then:

# Install
./install.sh destination_folder

# Get the socket location in profile
printf '. "$HOME/.posh_ssh'"\n" >> ~/.profile
. ~/.profile

To uninstall:

# Remove our service
launchctl remove world.farcloser.ssh_agent
# Re-enable the system service
launchctl enable gui/501/com.openssh.ssh-agent
launchctl start gui/501/com.openssh.ssh-agent

What is this doing exactly?

./install.sh will:

  • stop and disable the system ssh-agent launchctl agent
  • copy the run script farcloser-ssh-agent into destination_folder
  • install and start a user launch agent in ~/Library/LaunchAgents/world.farcloser.ssh_agent.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>world.farcloser.ssh_agent</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/dmp/Applications/bin/farcloser-ssh-agent</string>
            <string>/Users/dmp/Applications/homebrew/bin/ssh-agent</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
        <key>StandardOutPath</key>
        <string>/Users/dmp/Applications/homebrew/var/log/world.farcloser.ssh_agent-stdout.log</string>
        <key>StandardErrorPath</key>
        <string>/Users/dmp/Applications/homebrew/var/log/world.farcloser.ssh_agent-stderr.log</string>
    </dict>
</plist>

./farcloser-ssh-agent does:

  • check if it has been launched already
  • clean-up any possible socket remnant
  • exec the ssh-agent binary that has been passed as an argument

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages