Chef:部署一个禁用root ssh访问的服务器?
当我们配置新的
Linux服务器时,我们
>使用sudo权限创建一个新用户,并… 然后我们继续通过新用户帐户配置系统.当然我们这样做是因为我们的日志充满了恶意的ssh root登录尝试. 但现在我们正在尝试使用Chef(厨师独奏与刀独奏和图书管理员 – 厨师)来构建服务器.一旦我们创建了阻止从root登录ssh的配方,我们就无法再次运行配方. 我看到了这个: 有关如何创建可重新运行的Chef设置的任何想法,包括禁用root ssh访问? 解决方法
使用非root帐户引导服务器并不罕见.正如@StephenKing指出的那样,刀支持这一点.以下是我的正常程序:
ssh-copy-id me@hostname knife bootstrap hostname --ssh-user me --sudo --run-list role[desired_server_role] 但是,这个答案假设您正在使用厨师服务器(强烈推荐)…. 您正在使用非标准刀插件来模拟此引导行为. documentation声明sudo将被“knife solo prepare”命令使用:
并且“knife solo bootstrap”命令似乎支持与标准引导程序类似的选项. $knife solo bootstrap -h knife solo bootstrap [USER@]HOSTNAME [JSON] (options) --no-berkshelf Skip berks install --bootstrap-version VERSION The version of Chef to install -N,--node-name NAME The Chef node name for your new node --server-url URL Chef Server URL --chef-zero-port PORT Port to start chef-zero on -k,--key KEY API Client Key --[no-]color Use colored output,defaults to false on Windows,true otherwise -c,--config CONFIG The configuration file to use --defaults Accept default values for all questions -d,--disable-editing Do not open EDITOR,just accept the data as is -e,--editor EDITOR Set the editor to use for interactive commands -E,--environment ENVIRONMENT The Chef environment for your node --format FORMAT Which format to use for output --[no-]host-key-verify Verify host key,enabled by default. -i,--identity-file FILE The ssh identity file -j JSON_ATTRIBS,A JSON string to be added to node config (if it does not exist) --json-attributes --no-librarian Skip librarian-chef install -z,--local-mode Point knife commands at local repository instead of server -u,--user USER API Client Username --omnibus-options "OPTIONS" Pass options to the install.sh script --omnibus-url URL URL to download install.sh from --omnibus-version VERSION Deprecated. Replaced with --bootstrap-version. --prerelease Install the pre-release Chef version --print-after Show the data after a destructive operation -r,--run-list RUN_LIST Comma separated list of roles/recipes to put to node config (if it does not exist) -F CONFIG_FILE,Alternate location for ssh config file --ssh-config-file --ssh-identity FILE Deprecated. Replaced with --identity-file. -P,--ssh-password PASSWORD The ssh password -p,--ssh-port PORT The ssh port -x,--ssh-user USERNAME The ssh username -s,--startup-script FILE The startup script on the remote server containing variable definitions --sudo-command SUDO_COMMAND The command to use instead of sudo for admin privileges --sync-only Only sync the cookbook - do not run Chef -V,--verbose More verbose output. Use twice for max verbosity -v,--version Show chef version -W,--why-run Enable whyrun mode -y,--yes Say yes to all prompts for confirmation -h,--help Show this message 我注意到各种各样的时髦东西,包括使用厨师零的选项(现在在chef-client支持的功能). 希望这会有所帮助,但我建议考虑使用chef-server.站起来很容易,然后您将遵循使用厨师的标准方式. 更新 一个有趣的读物: > The future of knife-solo (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |