GithubHelp home page GithubHelp logo

clockwerx / chef-ssh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markolson/chef-ssh

0.0 3.0 0.0 71 KB

Chef cookbook for managing some mildly-difficult-to-automate SSH configuration

Ruby 100.00%

chef-ssh's Introduction

Chef SSH

Description

Provides 3 LWRPs to manage system-wide and per-user ssh_config and known_host files.

Setup

Include the ssh cookbook via Berkshelf or Librarian.

cookbook "ssh"

Or add the following line to your cookbook's metadata.rb.

depends "ssh"

Usage

When using SSH with Chef deployments, it's crucial to not get any prompts for input. Adding entries to known_hosts files and better managing your per-connection configuration can help with this.

An important thing to note is that if you create a user during a chef run, be sure to reload OHAI data so that the new user will be in the node data. For instance:

ohai "reload_passwd" do
    plugin "passwd"
end

The ssh cookbook bypasses this need somewhat by using ohai classes directly to discover your users' ssh paths. However some of your cookbooks may not be as generous.

Resources and Providers

known_hosts

Actions

ActionDescriptionDefault
add Adds an entry for the given host to a `known_hosts` file Yes
remove Removes entries for a host from a `known_hosts` file  

Attributes

AttributeDescriptionDefault Value
host Name attribute: the FQDN for a host to add to a `known_hosts` file nil
hashed A Boolean indicating if SSH is configured to use a hashed `known_hosts` file. true
key A full line to add to the file, instead of performing a lookup for the host. nil
user A username to add the `known_hosts` entry for. If unspecified, the known_host will be added system-wide. Note: if specified, the user must already exist. nil
path A full path to a known_hosts file. If used with the `user` attribute, this will take precedence over the path to a user's file, but the file will be created (if necessary) as that user. nil

Example

ssh_known_hosts "github.com" do
  hashed true
  user 'webapp'
end

config

Actions

ActionDescriptionDefault
add Adds an entry for the given host to a `ssh_config` file Yes
remove Removes entries for a host from a `ssh_config` file  

Attributes

AttributeDescriptionDefault Value
host Name attribute: the string to match when connecting to a host. This can be an IP, FQDN (github.com), or contain wildcards (*.prod.corp) nil
options A hash containing the key-values to write for the host in true
user A username to add the `ssh_config` entry for. If unspecified, the entry will be added system-wide. Note: if specified, the user must already exist. nil
path A full path to a ssh config file. If used with the `user` attribute, this will take precedence over the path to a user's file, but the file will be created (if necessary) as that user. nil

Example

ssh_config "github.com" do
  options 'User' => 'git', 'IdentityFile' => '/var/apps/github_deploy_key'
  user 'webapp'
end

authorized_keys

The authorized_keys LWRP is considered Beta due to the lack of tests for this resource. Use at your own risk, and feel free to submit a PR for adding more tests.

Also of important note, typically when SSH keys are generated, the resulting file will have the type, key, and a comment. The typical comment is just the username@host. This is NOT part of the key. When setting your attributes, please be sure to set only the key in the key field. See the example if you are still uncertain.

Actions

<\tr> <\tr>
ActionDescriptionDefault
add Adds an entry to the given user's authorized_keys file Yes
remove Removes an entry from the given user's authorized_keys file  
modify Updates an existing entry to the user's authorized_keys file, but only if the indicated `key` is present  

* please note that there is no name attribute for this resource. The name you assign is not used in the provider

Attributes

AttributeDescriptionDefault Value
type A string representing the type of key. Options include `id-rsa, ssh-dss, ssh-ed25519` and others id-rsa
options A hash containing the key-value pairs for options. Binary options such as `no-port-forwarding` should have a value of `nil` {}
user The user for which this key should be added none - __REQUIRED__
comment a comment to add to this entry (generally the `useranme@host` is added as a comment, but this is not required) ''
key the actual key none - __REQUIRED__

Example

ssh_authorized_key "for remote access" do options { 'cert-authority' => nil, :command => '/usr/bin/startup' } user 'admin' key 'AAAAB3NzaC1yc2EAAAADAQABAAACAQDzB76TOkrDRaevO3I1qzosRXliAuYdjcMejHwwL5v2hRqTrBePlMW6nqz8/JgLTzHn/KxzkrKLb0GlpPDrJ1KByWGYZsfydUfv7n1+5ogoA7UW7dUc4DoQtGPuy4Xe0enr88VfALlT11aWKAw8K/I39zWiPvJNX3Mks0f3/3smjLaQEnDWWWiawp5YgzJmyzsqZFZrrFCUgv7AP1EjZofWUcRvYEEjMhKsK+G2H2VCN7MpH0cJ97E0bKNQjHBrwGyMLQZUOndGakCuOuTLpikOXSpUUz5LwqCiRIj6iUtWevwk+AYLZwxPYQpCxFceVFDhPDaJQ85vweSq+HEg7hRujq9jO7vM9LIgjqg7fwQ2Ql6zO9NjXv2UalzBi0H2AbKT1V/PpNufPgolyb/dK7Jqpqu7Ytggctl2fGyLe8yVaC9gD+/BBeCl82LZI142kdXmf4WYcZgOgcRgGJrbSZjeMzX6zZpiD1AG3T7xyEn2twmC/TqptmQEAG2BBzGum+S6pU0rnOt2UJngRnviK2vptAWtRlSlsopySOXv+VbqUXhRjHRT/+2nq5Q4BWcjsZaaoo1uWh2glATRnGK995A1zJ3gWrBA+IaC6stKzjSG0KPwLjzHfPKbWjDX76D/qdo0qBN5hBiHDRfmiNqpNYS9NHACDZNVPBS5N1d5BUkyKw==' type 'id-rsa' comment '[email protected]' end

chef-ssh's People

Contributors

markolson avatar tejaycar avatar sliim avatar vincentgijsen avatar aki77 avatar rampire avatar analogj avatar joelwurtz avatar jwreagor avatar pierrerambaud avatar figadore avatar scottatron avatar tomduckering avatar btisdall avatar

Watchers

Daniel O'Connor avatar James Cloos avatar  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.