1. 首先需要安装Ruby 1.9之上的版本。
2. 安装Ruby DevKit (Development tools):
- 这里有安装步骤 https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
- 要注意的是,64位的一定要下载64位的devkit,不然会有莫名的错误
- 首先把下载下来的devkit解压,我解压到了Ruby的安装目录下: D:\Tools\Ruby\devKit。
- 使用Ruby命令行,进入该目录。
- 执行 ruby dk.rb init
- 编辑生成的 config.yml ,在里面需要加入你的Ruby路径,绝对路径用“ - ”开头,比如:<空格>-<空格>D:/Tools/Ruby
- 执行 ruby db.rb review 验证。
- 执行 ruby db.rb install --force 来强制安装。
- 执行 gem install json --platform=ruby 来验证。
我的config.yml 内容如下:
# This configuration file contains the absolute path locations of all
# installed Rubies to be enhanced to work with the DevKit. This config
# file is generated by the 'ruby dk.rb init' step and may be modified
# before running the 'ruby dk.rb install' step. To include any installed
# Rubies that were not automagically discovered, simply add a line below
# the triple hyphens with the absolute path to the Ruby root directory.
#
# Example:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
- D:/Tools/Ruby
3. 安装knife windows
- 执行 gem install knife-windows
4. 配置目标机器的WinRM:
winrm quickconfig -q
winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
winrm set winrm/config @{MaxTimeoutms="1800000"}
winrm set winrm/config/service @{AllowUnencrypted="true"}
winrm set winrm/config/service/auth @{Basic="true"}