执行时:
knife bootstrap {{IP}} --ssh-user centos --ssh-password '' \ --sudo --use-sudo-password --node-name node1 \ --run-list 'recipe[learn_chef_httpd]'
我收到以下错误:
ERROR: Net::SSH::AuthenticationFailed: Authentication failed for user centos@{{IP}}@{{IP}}
我试图连接到没有密码的centos用户,因为我想使用SSH-Key Auth。
我曾尝试通过一些排列组合:
knife bootstrap {{IP}} -x centos -i .chef/james-chef-validator.pem --sudo --run-list 'recipe[learn_chef_httpd]'
一切都没有成功…
如果运行-VV:
... DEBUG: allowed methods: publickey,gssapi-keyex,gssapi-with-mic DEBUG: none failed DEBUG: trying publickey DEBUG: connecting to ssh-agent ERROR: could not connect to ssh-agent ERROR: all authorization methods failed (tried none, publickey) ERROR: Net::SSH::AuthenticationFailed: Authentication failed for user centos@{{IP}}@{{IP}}
有任何想法吗?
修复!
所以,当你使用托pipe的厨师,你需要传递一个私人密钥的引导程序,并在您的autherized_keys文件的公钥…
~/chef-repo ssh-keygen $ cat id_rsa.pub >> authorized_keys 运行下面的刀引导程序:
sudo knife bootstrap {{server-ip}} --ssh-user {{your-server-user}} -i ~/.ssh/id_rsa --sudo --node-name web1
这应该工作!
我还build议您以–ssh用户身份通过的用户具有无密码sudo访问权限。
你需要的是ssh密钥。
最初,'node1'服务器(如下所述)将需要为您的'centos'用户设置一个密码(如下所示)。 一旦您为该用户设置了密码,请按照以下说明进行操作。
要设置它作为厨师用户login客户端服务器(一个运行的厨师)并运行
ssh-keygen -t rsa
按照说明(只需要input密码)
然后运行以下命令
ssh-copy-id <targetuser>@<targetserver>
按照屏幕上的说明,这就是它的一切。
厨师应该自动拿起SSH密钥。
编辑:
托pipe厨师的过程有点不同。 在厨师pipe理中,进入pipe理>用户>并select你的用户名。 在那里你应该看到一个公钥。
以目标用户身份login目标服务器,然后检查是否有〜/ .ssh目录
ls ~/.ssh
如果说“ls:无法访问〜/ .ssh:没有这样的文件或目录”运行
mkdir ~/.ssh
然后使用你select的命令行文件编辑器(我更喜欢VIM)创build文件〜/ .ssh / authorized_keys并将你在Hosted Chef上find的公钥复制到该文件中。
编辑:如果你的公钥是在格式开始:
-----BEGIN PUBLIC KEY-----
您首先需要将其转换为SSH公钥格式。
为此,请在本地计算机上创build一个名为publickey.pem的文件,并将公钥复制到该文件中。 然后打开一个terminal到那个位置并运行:
ssh-keygen -f publickey.pem -i -m PKCS8
希望这可以帮助。 蒂姆。
我不知道有谁使用Hosted Chef Server或本地Chef Server提供的密钥作为他们的SSHauthentication密钥,正如Tim所build议的。
Chef服务器提供的密钥通常只用于Chef客户端工具,如chef-client和knife,用于向Chef服务器的API进行身份validation。
为Timauthentication创build一个单独的密钥对,正如Tim的第一个回应和James的最终答案所表明的,是正确的select。 这可以手动完成,也可以使用Chef使用适当的SSH密钥来configuration系统。