Git Product home page Git Product logo

solo-agent's Introduction

solo-agent

Enable discrete SSH Agents to avoid leaking access across hosts

SSH Agent Security Issues

ForwardAgent Issue

  • Anyone with root access on a remote host you have forwarded your SSH Agent to can use the agent socket to access any host you have authorized that key on and can eavesdrop on your ongoing session.

ForwardAgent Resolution

  • Do not forward your SSH Agent. You do not need it to use ProxyCommand to connect through bastion/jump hosts (or ProxyJump with current versions of OpenSSH)
  • Use separate SSH Keys for different scopes (including read-only keys). Accomplish this by either:
    • Use solo-agent to isolate keys when ForwardAgent is needed (ex. for remote version control operations)
    • Or install the SSH key pair (ex. for remote version control operations) on the remote host. This option is less secure, but also less complex.

Install

  1. Install Homebrew -- The missing package manager for macOS
  2. Add the "tap":
    brew tap TimidRobot/tap
  3. Install solo-agent:
    brew install solo-agent
    

Alternatively, since solo-agent is a bash script without esoteric dependencies, you can simply download it and ensure it is in your PATH.

If this utility is helpful for you, please star this project so that it can eventually be included in Homebrew proper. Thank you!

Using solo-agent

  1. Assumptions:
    • You need to access GitHub from a host (devhost) on which a third-party has root access
    • You have already created a SSH key pair for use with GitHub and added to your GitHub account as a read-only key
    • The private key mentioned above is located on your laptop at: ~/.ssh/rsa_github_ro
    • You have cloned this repository to to your laptop. It is located at: ~/git/solo-agent
    • You have symlinked solo-agent to ~/bin/solo-agent
  2. At the top of your SSH configuration, put the Match exec that starts the SSH agent:
    Match exec "~/bin/solo-agent github_ro rsa_github_ro"
    
  3. In the middle of your SSH configuration, put the devhost stanza:
    Host devhost
        HostName devhost.example.com
        ForwardAgent Yes
        IdentityAgent ~/.ssh/solo-sock/github_ro
    
  4. At the bottom of your SSH configuration, ensure the global Host * stanza includes the following two options:
    Host *
        AddKeysToAgent no
        ForwardAgent no
    

Explanation

When you ssh devhost with the configuration above, the following will happen:

  1. The Match directive in the include will execute solo-agent. It will determine if there is already a valid socket symlinked from ~/.ssh/solo-sock/github_ro:
    • If there is, it will ensure the specified key is loaded into that agent
    • If not, it will start a new agent, create the symlink, and ensure the specified key is loaded into that agent
  2. The SSH connection to devhost will use the SSH Agent connected to the specified socket. Only the key(s) added to it will be available.
    • You can continue to authenticate to devhost with the IdentityFile of your choice without worry.

Requirements

  • OpenSSH 7.3 added IdentityAgent:
    • macOS 10.13 High Sierra or later
    • Red Hat Enterprise Linux 7 Update 4 or later
    • Ubuntu 17.04 Zesty Zapus or later
  • Either:
    • GNU coreutils readlink
    • Python

Alternatives

License

solo-agent's People

Contributors

timidrobot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

clockworknet

solo-agent's Issues

GNU ln compatibility patch

Using solo-agent on Linux. GNU ln does not have -h but it has -n
On the Mac, ln supports -n as an alias for -h, so to make solo-agent work on both,


~ diff -uN ~/bin/solo-agent.orig ~/bin/solo-agent    
--- ~/bin/solo-agent.orig  2020-06-15 23:47:04.000000000 -0400
+++ ~/bin/solo-agent   2020-12-13 20:19:58.241864747 -0500
@@ -126,7 +126,7 @@
     SSH_AUTH_SOCK="$(canonical_socket "${SSH_AUTH_SOCK}")"
     export SSH_AUTH_SOCK
     # Link to ID_SOCK for easy use/reference
-    ln -fhs "${SSH_AUTH_SOCK}" "${ID_SOCK}"
+    ln -fns "${SSH_AUTH_SOCK}" "${ID_SOCK}"
 fi
 # Display Variables
 display_variables

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.