Chef - 没有密码的 SSH

Jam*_*all 5 chef knife

执行时:

knife bootstrap {{IP}} --ssh-user centos --ssh-password '' \
--sudo --use-sudo-password --node-name node1 \
--run-list 'recipe[learn_chef_httpd]'
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

ERROR: Net::SSH::AuthenticationFailed: Authentication failed for user centos@{{IP}}@{{IP}}
Run Code Online (Sandbox Code Playgroud)

我正在尝试连接到没有密码的 centos 用户,因为我想使用 SSH-Key Auth。

我试过传递一些排列:

knife bootstrap {{IP}} -x centos -i .chef/james-chef-validator.pem  --sudo  --run-list 'recipe[learn_chef_httpd]'
Run Code Online (Sandbox Code Playgroud)

都没有成功...

如果使用 -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}}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Jam*_*all 5

修复!

因此,当您使用托管厨师时,您需要使用引导程序传递私钥,并在您的 autherized_keys 文件中包含公钥....

  1. 安装 ChefSDK
  2. 从托管的 Chef 中对您的入门套件进行 SCP
  3. 将入门套件提取到 ~/chef-repo
  4. 生成新的密钥对: ssh-keygen
  5. 将公钥添加到您的 autherized_keys 文件中: $ cat id_rsa.pub >> authorized_keys
  6. 使用以下命令运行刀具引导程序:

    sudo knife bootstrap {{server-ip}} --ssh-user {{your-server-user}} -i ~/.ssh/id_rsa --sudo --node-name web1

那应该工作!

我还建议您作为 --ssh-user 传递的用户具有无密码 sudo 访问权限。