Capistrano 入门
第3章 Windows环境下的 Capistrano
在上章《SSH SSH 公钥的设置》中已经介绍了在 Linux 和 Mac OS X 环境下,使用 Capistrano 的准备工作。
这章介绍Windows环境下的工作。
Capistrano 是使用 Ruby 的 Net::SSH 模块登陆远程服务器的。因此,ssh 的客户端程序基本上是不必要的。
在你电脑上的适当文件夹下创建一个如下内容的 Capfile 文件。
task :stamp, :hosts => "alpha.oiax.jp" do run "touch /home/kuroda/touched" end
然后执行 stamp 任务。
% cap stamp
* executing `stamp'
* executing "touch /home/kuroda/touched"
Password:
servers: ["alpha.oiax.jp"]
[alpha.oiax.jp] executing command
command finished
在此过程中,除了被要求密码外,与之前都相同。
在 windows 中,为了通过密钥实现 SSH 登陆,就要利用叫做 PuTTY 的免费软件。
从 PuTTY Download Page 上下载 putty-x.xx-installer.exe 并安装。
首先,运行 puttygen 程序,创建 SSH 公钥,保存密钥,在远程服务器的 authorized_keys 文件中添加公钥。详细请参照 PuTTYgen 的利用 。另外,不要忘记在文件 /home/app/.ssh/authorized_keys 上也添加公钥。
接下来启动 pageant 程序。这是一个常驻程序,启动后会在任务托盘里显示成一个戴着帽子的电脑的图标。双击该图标,将打开一个窗口“Pageant Key List”, 点击“Add Key”,选择刚刚保存下的密钥文件,将密钥注册到 pageant。
Windows 启动以后,只要事先进行过此步操作,则在执行 Capistrano 时不输入密码也可以。
% cap stamp
* executing `stamp'
* executing "touch /home/kuroda/touched"
servers: ["alpha.oiax.jp"]
[alpha.oiax.jp] executing command
command finished
[修订] 2008/05/17 配合以用户 app 登录远程主机的方式,对文章进行修改。
(2008/03/26)
- 前言
- 第1章 安装 (2008/03/24)
- 第2章 SSH公钥的设置 (2008/03/25)
- 第3章 Windows环境下的 Capistrano (2008/03/26)
- 第4章 capify (2008/03/27)
- 第5章 目标主机的准备 (2008/03/28)
- 第6章 deploy:update (2008/03/29)
- 第7章 Rails应用程序的启动、停止、重启 (2008/05/17)
- 第8章 deploy:rollback 与 deploy:cleanup (2008/05/18)
- 第9章 切换至维护页面 (2008/06/03)

