構成
--------------------
target_server
user: deploy
key: id_rsa.pemが必要
--------------------
^
|
--------------------
bastion_server.com
user: bastion_user
--------------------
^
|
--------------------
local
--------------------
config/deploy/production.rb
server "target_server", user: "deploy", roles: %w{app db web}, my_property: :my_value
set :ssh_options, {
keys: %w(~/.ssh/id_rsa.pem),
forward_agent: false,
user: 'deploy',
proxy: Net::SSH::Proxy::Command::new('ssh bastion_user@bastion_server.com -W %h:%p')
}
参考
config/deploy/production.rbの設定について
https://gist.github.com/chansuke/737784de811f140853239daa7b6b75ef
SSHのProxyCommandについて
https://dev.classmethod.jp/articles/direct-ssh-by-proxycommand/