GithubHelp home page GithubHelp logo

nickola / chef-ssh-keys Goto Github PK

View Code? Open in Web Editor NEW
52.0 5.0 36.0 275 KB

Cookbook "ssh-keys" for Chef, creates "authorized_keys" in user "~/.ssh" directory from a data bag

HTML 2.19% Ruby 97.81%
chef ssh

chef-ssh-keys's Introduction

Description

Creates authorized_keys in user ~/.ssh directory from a data bag (encrypted data bag supported).

Attributes

Expects node[:ssh_keys] to be an hash containing the user name as key and data bag user name as value. Also, users can be defined by groups (see usage examples below).

See attributes/default.rb for additional attributes default values.

Usage

Node configuration example to create authorized_keys for user root from data bag user user1:

{
  "ssh_keys": {
    "root": "user1"
  },
  "run_list": [
    "recipe[ssh-keys]"
  ]
}

Node configuration example to create authorized_keys for user root from data bag user user1 and user2:

{
  "ssh_keys": {
    "root": ["user1", "user2"]
  },
  "run_list": [
    "recipe[ssh-keys]"
  ]
}

Node configuration example to create authorized_keys for user root from users of group admin:

{
  "ssh_keys": {
    "root": {"groups": "admin"}
  },
  "run_list": [
    "recipe[ssh-keys]"
  ]
}

Node configuration example to create authorized_keys for user root from data bag user user1 and user2, and from users of groups admin and operator:

{
  "ssh_keys": {
    "root": {"users": ["user1", "user2"], "groups": ["admin", "operator"]}
  },
  "run_list": [
    "recipe[ssh-keys]"
  ]
}

Use knife to create a data bag for users:

knife data bag create users

User data bag example (compatible with Chef users cookbook):

knife data bag users user1
{
  "id": "user1",
  "ssh_keys": "ssh-rsa AAAAB3Nz...yhCw== user1"
}

knife data bag users user2
{
  "id": "user2",
  "ssh_keys": "ssh-rsa AAAAB3Nz...5D8F== user2"
}

Cookbook URLs

chef-ssh-keys's People

Contributors

5c077yp avatar cburroughs avatar enalmada avatar nickola avatar zarry avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

chef-ssh-keys's Issues

Error when doing knife cookbook site install ssh-keys

eloy@dellta:/srv/repo/chlor-chef-repo$ knife cookbook site install ssh-keys
Installing ssh-keys to /srv/repo/chlor-chef-repo/cookbooks
Checking out the master branch.
Pristine copy branch (chef-vendor-ssh-keys) exists, switching to it.
Downloading ssh-keys from the cookbooks site at version 1.0.0 to /srv/repo/chlor-chef-repo/cookbooks/ssh-keys.tar.gz
Cookbook saved: /srv/repo/chlor-chef-repo/cookbooks/ssh-keys.tar.gz
Removing pre-existing version.
Uncompressing ssh-keys version 1.0.0.
removing downloaded tarball
1 files updated, committing changes
ERROR: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
---- Begin output of git add ssh-keys ----
STDOUT:
STDERR: fatal: Not a git repository: /Users/Nickola/Development/.chef/.git/modules/site-cookbooks/ssh-keys
---- End output of git add ssh-keys ----
Ran git add ssh-keys returned 128

`line.start_with?("ssh")` is not a good test...

... since valid keys can begin with "ssh", or "ecdsa", or "ed25519" - and likely more types in the future.

Additionally, why be selective at all - de-duplicating is fair enough, but if the user has additional entries or comments in their existing file, why not simply maintain these and add any new keys if they don't already exist?

All the best,

Stuart

symlinked authorized_keys file

On some servers the file .ssh/authorized_keys is a symlink

As it is a symlink, the recipe fails to update the file. It cannot create a new file .ssh/authorized_keys

Feature request for symlinked files: truncate the file and add the keys.

git tags

please push git tags to github... it helps to understand "where i am" from local checkout:

โž” git describe --tags
fatal: No names found, cannot describe anything.

If users home directory does not exist, fails to create necessary directory structure and errors out.

If users home directory does not exist, recipe fails to create necessary directory structure and errors out.

I ran into an issue where a users home directory was manually removed. This failed the chef run as the needed directory structure was not present. This presented itself as an issue because of this currently open chef bug. CHEF-2409

Adding recursive true to the directory call will solve this issue and prevent a chef run from failing.

Release on supermarket

Hi,

Can you release your cookbook on the supermarket, since Chef12, the cookbook currently on it could not be run because name isn't present in metadata.rb. I see you already fixed it but not on the supermarket.

Regards,

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.