Giter Site home page Giter Site logo

papigronic / sf-keys Goto Github PK

View Code? Open in Web Editor NEW

This project forked from serverfarmer/sf-keys

0.0 1.0 0.0 12 KB

sf-keys extension provides ssh/gpg public keys used by Server Farmer.

Home Page: http://serverfarmer.org/

License: MIT License

Shell 100.00%

sf-keys's Introduction

sf-keys extension for Server Farmer

sf-keys is a very special extension - the only one, that is not cloned to managed servers directly from the original repository. Instead, you are supposed to fork it and replace all gpg/ssh keys with your own ones. Then, url of your forked repository should be placed into scripts/functions.custom file in Server Farmer main repository.

Why all keys are stored in a separate repository?

When your farm will grow up, you will probably use multiple Server Farmer forked repositories, eg. main fork as the primary version (for most customers), and several separately fine-tuned versions to handle particular customers. All these forks can (and should) share the same sf-keys repository, which greatly reduces the error surface related to key management.

Key types and roles

security model

All ssh keys used by Server Farmer are stored in /etc/local/.ssh directory on farm manager, which is the main management server. Security of this server is absolutely critical, as anyone who can access it, can do literally everything with your whole network, as well as with all networks, servers, domains etc. managed for your customers.

To increase the overall security level, you can use master and slave farm managers, where master is the only one with management ssh private keys, while dedicated ssh private keys are copied to slave farm managers after generation.

management key

Is ssh key used:

  • in host setup phase, to attach new host to the farm and allow generating dedicated keys
  • by main administrator (should be used only if dedicated keys are not available)

dedicated key

Is ssh key used:

  • for passwordless ssh root access from farm manager after the setup phase (this key is generated automatically during setup)
  • for transferring backups from managed server to backup collector (this key is also generated automatically, for backup system user)
  • for other administrators and any other people that should have access to particular managed server

Files/directories overview

gpg part

gpg/ - this directory contains all your gpg public keys

functions - this file should expose gpg_backup_key shell function:

  • it is very important, that this file should work in standard /bin/sh shell, without requiring Bash
  • gpg_backup_key function should return either empty string, or gpg file name without .pub extension
  • key with returned filename (with .pub extension) should be present in gpg/ directory

ssh part

ssh/ - this directory contains all your ssh public keys (including the one named id.default)

get-ssh-dedicated-key.sh - this script prints the full filename (including path) of dedicated ssh private key - in most cases, you shouldn't touch it

get-ssh-device-key.sh - this script prints the full filename of ssh private key used on MikroTik/Cisco network devices - default version of this script assumes, that all devices of given brand share one key, you can change this script if you want to use different key for each router

get-ssh-management-key-content.sh - important script - this script prints the contents of management ssh public key (as single line: ssh-rsa AAAAB3Nza..... root@host)

  • this key will be attached to /root/.ssh/authorized_keys file
  • script takes one argument: hostname (so you can use many keys and choose the proper one based on hostname)

get-ssh-management-key.sh - important script - this script prints the the full filename (including path) of management ssh private key

  • script takes one argument: hostname - printed private key should match the public key printed by get-ssh-management-key-content.sh script
  • this key should never be disclosed to anyone, even other administrators
  • if this script is executed on host without management key, it should instead print the full filename of dedicated ssh private key for given hostname - so other administrators are also able to use Server Farmer management tools, assuming that they have at least the dedicated key for particular host they want to manage

custom logic

setup.sh - this script is re-executed each time Server Farmer setup is executed, and is responsible for:

  • installing ssh management public key on current host in /root/.ssh/authorized_keys file
  • executing any custom logic you want to execute on all hosts in the farm

sf-keys's People

Contributors

tomaszklim avatar

Watchers

James Cloos avatar

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.