capistrano3で認証エラー


capコマンドで以下のエラーが出力された

```
$ cap production deploy
・・・
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ***@***.***.***.***: Authentication failed for user ***@***.***.***.***
```

設定を見なおしたところ、ssh_optionsを使って鍵を指定する必要があった。

```
# 例
set :ssh_options, {
  user: '***',
  keys: %w(/home/***/.ssh/id_rsa),
  forward_agent: false,
  auth_methods: %w(publickey)
}
```

以下、使えるオプションを転記。
事前にひと通り見ておいたほうが良さそう。
参考 : [Net::SSH](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)

```
:auth_methods => an array of authentication methods to try

:bind_address => the IP address on the connecting machine to use in establishing connection. (:bind_address is discarded if :proxy is set.)

:compression => the compression algorithm to use, or true to use whatever is supported.

:compression_level => the compression level to use when sending data

:config => set to true to load the default OpenSSH config files (~/.ssh/config, /etc/ssh_config), or to false to not load them, or to a file-name (or array of file-names) to load those specific configuration files. Defaults to true.

:encryption => the encryption cipher (or ciphers) to use

:forward_agent => set to true if you want the SSH agent connection to be forwarded

:global_known_hosts_file => the location of the global known hosts file. Set to an array if you want to specify multiple global known hosts files. Defaults to %w(/etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2).

:hmac => the hmac algorithm (or algorithms) to use

:host_key => the host key algorithm (or algorithms) to use

:host_key_alias => the host name to use when looking up or adding a host to a known_hosts dictionary file

:host_name => the real host name or IP to log into. This is used instead of the host parameter, and is primarily only useful when specified in an SSH configuration file. It lets you specify an "alias", similarly to adding an entry in /etc/hosts but without needing to modify /etc/hosts. :keepalive => set to true to send a keepalive packet to the SSH server when there's no traffic between the SSH server and Net::SSH client for the keepalive_interval seconds. Defaults to false. :keepalive_interval => the interval seconds for keepalive. Defaults to 300 seconds.

:kex => the key exchange algorithm (or algorithms) to use

:keys => an array of file names of private keys to use for publickey and hostbased authentication

:key_data => an array of strings, with each element of the array being a raw private key in PEM format.

:keys_only => set to true to use only private keys from keys and key_data parameters, even if ssh-agent offers more identities. This option is intended for situations where ssh-agent offers many different identites.

:logger => the logger instance to use when logging

:max_pkt_size => maximum size we tell the other side that is supported per packet. Default is 0x8000 (32768 bytes). Increase to 0x10000 (65536 bytes) for better performance if your SSH server supports it (most do).

:max_win_size => maximum size we tell the other side that is supported for the window.

:paranoid => either false, true, :very, or :secure specifying how strict host-key verification should be (in increasing order here)

:passphrase => the passphrase to use when loading a private key (default is nil, for no passphrase)

:password => the password to use to login

:port => the port to use when connecting to the remote host

:properties => a hash of key/value pairs to add to the new connection's properties (see Net::SSH::Connection::Session#properties)

:proxy => a proxy instance (see Proxy) to use when connecting

:rekey_blocks_limit => the max number of blocks to process before rekeying

:rekey_limit => the max number of bytes to process before rekeying

:rekey_packet_limit => the max number of packets to process before rekeying

:send_env => an array of local environment variable names to export to the remote environment. Names may be given as String or Regexp.

:timeout => how long to wait for the initial connection to be made

:user => the user name to log in as; this overrides the user parameter, and is primarily only useful when provided via an SSH configuration file.

:user_known_hosts_file => the location of the user known hosts file. Set to an array to specify multiple user known hosts files. Defaults to %w(~/.ssh/known_hosts ~/.ssh/known_hosts2).

:use_agent => Set false to disable the use of ssh-agent. Defaults to true

:verbose => how verbose to be (Logger verbosity constants, Logger::DEBUG is very verbose, Logger::FATAL is all but silent). Logger::FATAL is the default. The symbols :debug, :info, :warn, :error, and :fatal are also supported and are translated to the corresponding Logger constant.
```

ということで、鍵周りの設定は意外と忘れがちなので、注意。