Tags


The passwordless SSH worked well in my lab. Here is the how to:

1) Let the user generate the key pair, then copy the .pub file to the modules/sys_key/files folder and name it after the user’s name.

Selection_010

2) Copy /etc/skel/.bashrc and .bash_profile to modules/sys_key/files folder.

3) Create the the manifests files in module/sys_key/manifests. It can be download from here.

copy_key.pp

define sys_key::copy_key ($user) {

file { “/home/$user/”:
ensure => directory,
owner => $user,
#group => $user,
mode => 700,
replace => false,
}

file { “/home/$user/.ssh”:
ensure => directory,
owner => $user,
#group => $user,
mode => 700,
}

file { “/home/$user/.bash_profile”:
ensure => present,
owner => $user,
#group => $user,
source => “puppet:///sys_key/.bash_profile”,
}

file { “/home/$user/.bashrc”:
ensure => present,
owner => $user,
#group => $user,
source => “puppet:///sys_key/.bashrc”,
}

file { “/home/$user/.ssh/authorized_keys”:
ensure => present,
owner => $user,
#group => $user,
mode => 600,
source => “puppet:///sys_key/$user.pub”,
require => File[“/home/$user/.ssh”],
}

}

init.pp

class sys_key {
sys_key::copy_key { ‘jchen’: user => ‘jchen’ }
}

4) Apply the puppet tag, and test the paswordless ssh connection.

Selection_012

Selection_011

Advertisements