• Stars
    star
    395
  • Rank 109,040 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sharkey is a service for managing certificates for use by OpenSSH

say no to TOFU

sharkey

license development status tests report

Sharkey is a service for managing certificates for use by OpenSSH.

sharks

Sharkey has a client component and a server component. The server is responsible for issuing signed host certificates, the client is responsible for installing host certificates on machines. Sharkey builds on the trust relationships of your existing X.509 PKI to manage trusted SSH certificates. Existing X.509 certificates can be minted into SSH certificates, so you don't have to maintain two separate PKI hierarchies.

Build

Check out the repository, and build client/server:

go build -o sharkey-client ./client
go build -o sharkey-server ./server

Server

The server component accepts requests and issues short lived host certificates.

Clients send their public key to the server (via TLS with mutual authentication) periodically. The server authenticates the client by checking that its certificate is valid for the requested hostname. If everything looks good, the server will take the public key in the request and issue an OpenSSH host certificate for the requested hostname.

A log of all issued certificates is stored in a database. The server can generate a known_hosts file from the issuance log if required.

Usage:

usage: sharkey-server --config=CONFIG [<flags>] <command> [<args> ...]

Certificate issuer of the ssh-ca system.

Flags:
  --help           Show context-sensitive help (also try --help-long and --help-man).
  --config=CONFIG  Path to config file for server.
  --version        Show application version.

Commands:
  help [<command>...]
    Show help.

  start
    Run the sharkey server.

  migrate [<flags>]
    Set up database/run migrations.

Configuration (example):

# SQLite database
# ---
db:
  address: /path/to/sharkey.db
  type: sqlite

# MySQL database
# ---
# db:
#   username: root
#   password: password
#   address: hostname:port
#   schema: ssh_ca
#   type: mysql
#   tls:                                       # MySQL TLS config (optional)
#     ca: /path/to/mysql-ca-bundle.pem
#     cert: /path/to/mysql-client-cert.pem     # MySQL client cert
#     key: /path/to/mysql-client-cert-key.pem  # MySQL client cert key

# Server listening address
listen_addr: "0.0.0.0:8080"

# TLS config for serving requests
# ---
tls:
  ca: /path/to/ca-bundle.pem
  cert: /path/to/server-certificate.pem
  key: /path/to/server-certificate-key.pem

# Signing key (from ssh-keygen)
signing_key: /path/to/ca-signing-key

# Lifetime/validity duration for generated host certificates
host_cert_duration: 168h

# Lifetime/validity duration for generated user certificates
user_cert_duration: 24h

# Optional suffix to strip from client hostnames when generating certificates.
# This is useful if all your machines have a common TLD/domain, and you want to
# include an alias in the generated certificate that doesn't include that suffix.
# Leave empty to disable
strip_suffix: ".example.com"

# Optional set of aliases for hosts. If a hostname matches an alias entry, the
# listed principals will be added to its certificate. This is useful if you have
# special hosts that are accessed via CNAME records.
aliases:
  "host.example.com":
    - "alias1.example.com"
    - "alias2.example.com"

# Optional set of extra entries to provide to clients when they fetch a known_hosts
# file. This is useful if you have externally-managed servers in your infrastructure
# that you want to tell clients about, of if you want to add CA entries to the
# known_hosts file.
extra_known_hosts:
  - "@cert-authority *.example.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBwhA8rKPESjDy4iqTlkBqUlBU2xjwtmFUHY6cutA9TYbB5H/mjxzUpnSNw/HyFWNpysjTSQtHWWBdJdJGU/0aDgFUwbduHeDFxviGVSkOxm2AYn7XJopzITZRqmAmsYXHUBa75RQb+UgIG7EpCoi8hF4ItJV+TT777j1irkXwlMmeDiJEaA+7bPNdUdGw8zRbk0CyeotYVD0griRtkXdfgnQAu+DvBwOuW/uiZaPz/rAVjt4b9fmp6pcFKI3RsBqqn5tQVhKCPVuSwqvIQ7CTVkMClYovlH1/zGe8PG1DHbM9irP98S5j3mVD9W5v3QILpsg24RIS14M8pLarlD6t root@authority"

# User certs are issued to users who connect through an authenticating proxy
# That user should connect with a user certificate and set the username
# in a header.
auth_proxy:
  # Hostname is validated against the incoming user certificate
  hostname: proxy.example.com
  # The HTTP header containing the username
  username_header: X-Forwarded-User

# Optional settings related to SSH
ssh:
  # List of extensions that should be set on the user certificate (default is no extensions)
  user_cert_extensions:
    - "permit-X11-forwarding"
    - "permit-agent-forwarding"
    - "permit-port-forwarding"
    - "permit-pty"
    - "permit-user-rc"

A signing key for generating host certificates can be generated with ssh-keygen.

Database

Sharkey supports both SQLite and MySQL. There is a built-in command in the server binary to manage migrations (based on goose).

To run migrations on a configured database:

# SQLite
./sharkey-server --config=[CONFIG] migrate --migrations=db/sqlite

# MySQL
./sharkey-server --config=[CONFIG] migrate --migrations=db/mysql

You can also manage migrations using the goose command-line utility. See the goose documentation for more info.

Client

The client component periodically requests a new host certificate from the server and installs it on the machine.

The client will use a TLS client certificate to make a connection to the server and authenticate itself. This assumes that there is a long-lived certificate and key installed on each machine that uses the client. We then periodically read the host key for the locally running OpenSSH (host_key), send it to the server, and retrieve a signed host certificate based on that key. The signed host certificate is then installed on the machine (signed_cert).

Usage:

usage: sharkey-client --config=CONFIG [<flags>]

Flags:
  --help           Show context-sensitive help (also try --help-long and --help-man).
  --config=CONFIG  Path to yaml config file for setup
  --version        Show application version.

Configuration (example):

# Server address
request_addr: "https://sharkey-server.example:8080"

# TLS config for making requests
# ---
tls:
  ca: /path/to/ca-bundle.pem
  cert: /path/to/client-certificate.pem
  key: /path/to/client-certificate-key.pem

# List of host keys for OpenSSH server
host_keys:
  # Here, 'key' is the public key, and 'cert' is where to install the signed cert
  - plain: "/etc/ssh/ssh_host_rsa_key.pub"
    signed: "/etc/ssh/ssh_host_rsa_key-cert.pub"
  # You can specify multiple host keys (e.g. if you have both RSA, ED25519 keys)
  - plain: "/etc/ssh/ssh_host_ed25519_key.pub"
    signed: "/etc/ssh/ssh_host_ed25519_key-cert.pub"

# Where to install the known_hosts file
known_hosts: /etc/ssh/known_hosts

# If set to true, only install authorities in known_hosts file (ignore other machine's host keys).
known_hosts_authorities_only: false

# How often to refresh/request new certificate
sleep: "24h"

# Path to sudo binary on client host
# Uses sudo to write known_hosts and signed_cert.pub if this field specified
sudo: "/usr/bin/sudo"

# Command to restart ssh daemon for the host
# If sudo is set as well, this command will be prefixed with 'sudo'
ssh_reload: ["/usr/sbin/service", "ssh", "restart"]

OpenSSH will have to be configured to read the signed host certificate (this is with the HostCertificate config option in sshd_config). If the signed host certificate is missing from disk, OpenSSH will fall back to TOFU with the default host key. Therefore, it should always be safe to configure a host certificate; even if the Sharkey client fails you can still SSH into your machine.

User Certificates

For a user to SSH into an openssh server, they can present a certificate, which should have a principal matching their username. Sharkey outsources identifying users to an SSO proxy. That proxy needs to connect to sharkey over mTLS. You can configure the DNS SAN that should appear on the server's client cert (eg, proxy.example.com) and the HTTP header it sets the username to (eg, X-Forwarded-User). See example configs.

No client helper is included with Sharkey at this time, so you have to set up a script yourself at this time to enroll the user.

Testing looks something like this: curl --cert proxy.crt --key proxy.key https://localhost:8080/enroll_user -H "X-Forwarded-User: bob" -d @~/.ssh/bob.pub

But in production use you'd expect it more like curl <auth to your proxy> https://ssoproxy.example.com/enroll_user -d @~/.ssh/bob.pub

GitHub SSH CA Support

Sharkey supports issuing user certificates that are compatible with GitHub SSH CA format by:

  • Mapping a GitHub username to a SAML identity
  • Including appropriate GitHub username in each certificate

GitHub supports authentication using SSH certificates for Enterprise Cloud accounts. The only requirement is that certificates include GitHub usernames, so that they can be matched to a particular user.

Sharkey already requires SSO proxy for the user certificate feature. Additionally, the GitHub integration requires that the GitHub organization is configured with SSO (i.e. non-GitHub) access.

An example config with GitHub SSH CA Support enabled can be found in test/git_server_config.yaml. A GitHub App with read/write access to Organization:members is required.

Sharkey will periodically query GitHub for a mapping of SAML identities to GitHub usernames and store it in Sharkey's DB. When issuing a certificate, Sharkey will check the DB and if a mapping exists, attaches it to the certificate as an extension.

An example cert is shown below:

        Type: [email protected] user certificate
        Public key: RSA-CERT SHA256:Eabuov2aAPLhN1FscJ6P3Lle85N6Txhj4sy4ALTkG6M
        Signing CA: ED25519 SHA256:HYgRf1dHbVtWY/e3jjfnAlwvAPPBKYxdXz8SDfhlAws (using ssh-ed25519)
        Key ID: "alice"
        Serial: 1
        Valid: from 2020-07-31T16:10:25 to 2020-08-01T16:10:25
        Principals:
                alice
        Critical Options: (none)
        Extensions:
                [email protected] UNKNOWN OPTION (len 5)
                permit-X11-forwarding
                permit-agent-forwarding
                permit-port-forwarding
                permit-pty
                permit-user-rc

Telemetry

Sharkey supports sending DogStatsD metrics. Currently only metrics regarding GitHub SSH CA are being emitted. Adding the following block to the server configuration will enable metrics:

telemetry:
  address: "127.0.0.1:8200"

Unix sockets are also supported.

More Repositories

1

okhttp

Squareโ€™s meticulous HTTP client for the JVM, Android, and GraalVM.
Kotlin
45,794
star
2

retrofit

A type-safe HTTP client for Android and the JVM
HTML
43,053
star
3

leakcanary

A memory leak detection library for Android.
Kotlin
29,383
star
4

picasso

A powerful image downloading and caching library for Android
Kotlin
18,716
star
5

javapoet

A Java API for generating .java source files.
Java
10,820
star
6

moshi

A modern JSON library for Kotlin and Java.
Kotlin
9,756
star
7

okio

A modern I/O library for Android, Java, and Kotlin Multiplatform.
Kotlin
8,790
star
8

dagger

A fast dependency injector for Android and Java.
Java
7,308
star
9

crossfilter

Fast n-dimensional filtering and grouping of records.
JavaScript
6,217
star
10

PonyDebugger

Remote network and data debugging for your native iOS app using Chrome Developer Tools
Objective-C
5,864
star
11

maximum-awesome

Config files for vim and tmux.
Ruby
5,706
star
12

otto

An enhanced Guava-based event bus with emphasis on Android support.
Java
5,163
star
13

cubism

Cubism.js: A JavaScript library for time series visualization.
JavaScript
4,943
star
14

sqlbrite

A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to SQL operations.
Java
4,570
star
15

android-times-square

Standalone Android widget for picking a single date from a calendar view.
Java
4,445
star
16

wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
Kotlin
4,244
star
17

Valet

Valet lets you securely store data in the iOS, tvOS, watchOS, or macOS Keychain without knowing a thing about how the Keychain works. Itโ€™s easy. We promise.
Swift
3,989
star
18

cube

Cube: A system for time series visualization.
JavaScript
3,904
star
19

kotlinpoet

A Kotlin API for generating .kt source files.
Kotlin
3,896
star
20

java-code-styles

IntelliJ IDEA code style settings for Square's Java and Android projects.
Shell
2,957
star
21

flow

Name UI states, navigate between them, remember where you've been.
Java
2,786
star
22

spoon

Distributing instrumentation tests to all your Androids.
HTML
2,702
star
23

keywhiz

A system for distributing and managing secrets
Java
2,619
star
24

tape

A lightning fast, transactional, file-based FIFO for Android and Java.
Java
2,466
star
25

certstrap

Tools to bootstrap CAs, certificate requests, and signed certificates.
Go
2,282
star
26

mortar

A simple library that makes it easy to pair thin views with dedicated controllers, isolated from most of the vagaries of the Activity life cycle.
Java
2,157
star
27

go-jose

An implementation of JOSE standards (JWE, JWS, JWT) in Go
1,975
star
28

Cleanse

Lightweight Swift Dependency Injection Framework
Swift
1,784
star
29

assertj-android

A set of AssertJ helpers geared toward testing Android.
Java
1,577
star
30

haha

DEPRECATED Java library to automate the analysis of Android heap dumps.
Java
1,436
star
31

phrase

Phrase is an Android string resource templating library
Java
1,404
star
32

cane

Code quality threshold checking as part of your build
Ruby
1,325
star
33

anvil

A Kotlin compiler plugin to make dependency injection with Dagger 2 easier.
Kotlin
1,310
star
34

seismic

Android device shake detection.
Java
1,275
star
35

sudo_pair

Plugin for sudo that requires another human to approve and monitor privileged sudo sessions
Rust
1,240
star
36

square.github.io

A simple, static portal which outlines our open source offerings.
CSS
1,153
star
37

spacecommander

Commit fully-formatted Objective-C as a team without even trying.
Objective-C
1,126
star
38

workflow

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Shell
1,124
star
39

workflow-kotlin

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Kotlin
1,027
star
40

certigo

A utility to examine and validate certificates in a variety of formats
Go
941
star
41

logcat

I CAN HAZ LOGZ?
Kotlin
895
star
42

radiography

Text-ray goggles for your Android UI.
Kotlin
852
star
43

whorlwind

Makes fingerprint encryption a breeze.
Java
817
star
44

dagger-intellij-plugin

An IntelliJ IDEA plugin for Dagger which provides insight into how injections and providers are used.
Java
796
star
45

cycler

Kotlin
791
star
46

Paralayout

Paralayout is a set of simple, useful, and straightforward utilities that enable pixel-perfect layout in iOS. Your designers will love you.
Swift
786
star
47

apropos

A simple way to serve up appropriate images for every visitor.
Ruby
764
star
48

shift

shift is an application that helps you run schema migrations on MySQL databases
Ruby
735
star
49

coordinators

Simple MVWhatever for Android
Java
702
star
50

subzero

Block's Bitcoin Cold Storage solution.
C
683
star
51

Blueprint

Declarative UI construction for iOS, written in Swift
Swift
672
star
52

shuttle

String extraction, translation and export tools for the 21st century. "Moving strings around so you don't have to"
Ruby
656
star
53

gifencoder

A pure Java library implementing the GIF89a specification. Suitable for use on Android.
Java
654
star
54

pollexor

Java client for the Thumbor image service which allows you to build URIs in an expressive fashion using a fluent API.
Java
633
star
55

intro-to-d3

a D3.js tutorial
CSS
602
star
56

kochiku

Shard your builds for fun and profit
Ruby
599
star
57

curtains

Lift the curtain on Android Windows!
Kotlin
570
star
58

svelte-store

TypeScript
524
star
59

RxIdler

An IdlingResource for Espresso which wraps an RxJava Scheduler.
Java
511
star
60

burst

A unit testing library for varying test data.
Java
464
star
61

field-kit

FieldKit lets you take control of your text fields.
JavaScript
463
star
62

SuperDelegate

SuperDelegate provides a clean application delegate interface and protects you from bugs in the application lifecycle
Swift
454
star
63

otto-intellij-plugin

An IntelliJ IDEA plugin to navigate between events posted by Otto.
Java
451
star
64

js-jose

JavaScript library to encrypt/decrypt data in JSON Web Encryption (JWE) format and to sign/verify data in JSON Web Signature (JWS) format. Leverages Browser's native WebCrypto API.
JavaScript
422
star
65

connect-api-examples

Code samples demonstrating the functionality of the Square Connect API
JavaScript
391
star
66

fdoc

Documentation format and verification
Ruby
380
star
67

ETL

Extract, Transform, and Load data with Ruby
Ruby
377
star
68

lgtm

Simple object validation for JavaScript.
JavaScript
370
star
69

papa

PAPA: Performance of Android Production Applications
Kotlin
345
star
70

laravel-hyrule

Object-oriented, composable, fluent API for writing validations in Laravel
PHP
341
star
71

in-app-payments-flutter-plugin

Flutter Plugin for Square In-App Payments SDK
Objective-C
340
star
72

pylink

Python Library for device debugging/programming via J-Link
Python
331
star
73

workflow-swift

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Swift
326
star
74

pysurvival

Open source package for Survival Analysis modeling
HTML
319
star
75

rails-auth

Modular resource-based authentication and authorization for Rails/Rack
Ruby
291
star
76

cocoapods-generate

A CocoaPods plugin that allows you to easily generate a workspace from a podspec.
Ruby
279
star
77

inspect

inspect is a collection of metrics gathering, analysis utilities for various subsystems of linux, mysql and postgres.
Go
268
star
78

Aardvark

Aardvark is a library that makes it dead simple to create actionable bug reports.
Objective-C
260
star
79

gradle-dependencies-sorter

A CLI app and Gradle plugin to sort the dependencies in your Gradle build scripts
Kotlin
253
star
80

jetpack

jet.pack: package your JRuby rack app for Jetty.
Ruby
248
star
81

luhnybin

Shell
232
star
82

auto-value-redacted

An extension for Google's AutoValue that omits redacted fields from toString().
Java
211
star
83

protoparser

Java parser for .proto schema declarations.
Java
210
star
84

squalor

Go SQL utility library
Go
205
star
85

Listable

Declarative list views for iOS apps.
Swift
200
star
86

p2

Platypus Platform: Tools for Scalable Deployment
Go
196
star
87

mimecraft

Utility for creating RFC-compliant multipart and form-encoded HTTP request bodies.
Java
195
star
88

git-fastclone

git clone --recursive on steroids
Ruby
187
star
89

zapp

Continuous Integration for KIF
Objective-C
179
star
90

metrics

Metrics Query Engine
Go
170
star
91

ruby-rrule

RRULE expansion for Ruby
Ruby
170
star
92

quotaservice

The purpose of a quota service is to prevent cascading failures in micro-service environments. The service acts as a traffic cop, slowing down traffic where necessary to prevent overloading services. For this to work, remote procedure calls (RPCs) between services consult the quota service before making a call. The service isnโ€™t strictly for RPCs between services, and can even be used to apply quotas to database calls, for example.
Go
153
star
93

wire-gradle-plugin

A Gradle plugin for generating Java code for your protocol buffer definitions with Wire.
Groovy
153
star
94

goprotowrap

A package-at-a-time wrapper for protoc, for generating Go protobuf code.
Go
148
star
95

beancounter

Utility to audit the balance of Hierarchical Deterministic (HD) wallets. Supports multisig + segwit wallets.
Go
144
star
96

rce-agent

gRPC-based Remote Command Execution Agent
Go
136
star
97

womeng_handbook

Everything you need to start or expand a women in engineering group in your community.
129
star
98

cocoapods-check

A CocoaPods plugin that shows differences between locked and installed Pods
Ruby
126
star
99

point-of-sale-android-sdk

A simple library for letting Point of Sale take in-store payments for your app using Point of Sale API.
Java
119
star
100

in-app-payments-react-native-plugin

Objective-C
119
star