I tried running chef bootstrap using public key on amazon ec2 server, and get some errors:
ERROR: ArgumentError: invalid option(s): keys_only
Or
/usr/lib/ruby/1.8/net/ssh.rb:155:in `start': invalid option(s): keys_only (ArgumentError)
well, i don't know if it is a bug, but i create a simple solution for this with a simple script
the following script will allow password, run bootstrap and disallow password
This script will change the PasswordAuthentication in /etc/ssh/sshd_config
will add password: PASSWORD
will run the bootstrap
and finally will block using password.
vi knife_add_new_node.sh
#!/bin/bash
if [ $# -ne 2 ]
then
echo "please run the script as follow: $0 keyname.pem server-address"
else
ssh -i ${1} root@${2} "sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config;echo root:PASSWORD | chpasswd;/etc/init.d/ssh restart"
knife bootstrap ${2} -x root -P PASSWORD
ssh -i ${1} root@${2} "sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config;/etc/init.d/ssh restart"
fi

No comments:
Post a Comment