This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.

Kanrisuru

Connection to Remote Host

To connect with Kanrisuru to a remote host, provide the login credentials when instanting a Kanrisuru::Remote::Host.

host = Kanrisuru::Remote::Host.new(
  host: 'remote-host-name', 
  username: 'ubuntu', 
  keys: ['~/.ssh/id_rsa']
)

Jump / Bastion Host

To connect to a host behind a firewall through a jump / bastion host, pass either an instance of another Kanrisuru::Remote::Host, or a hash of host config values

proxy = Kanrisuru::Remote::Host.new(
  host: 'proxy-host',
  username: 'ubuntu',
  keys: ['~/.ssh/proxy.pem']
)

host = Kanrisuru::Remote::Host.new(
  host: '1.2.3.4', 
  username: 'ubuntu', 
  keys: ['~/.ssh/id_rsa'],
  proxy: proxy
)

host.whoami
'ubuntu'

Localhost

You can also run commands locall with a localhost connection, via localhost / 127.0.0.1 hostname. We recommend being careful when testing on the same system that kanrisuru is operating on.

host = Kanrisuru::Remote::Host.new(
  host: 'localhost', 
  username: 'ubuntu', 
  keys: ['~/.ssh/id_rsa']
)

Connecting with a Password

To connect to a host with a password login, simply provide the password in the host instantiation instead of the key.

host = Kanrisuru::Remote::Host.new(
  host: 'localhost', 
  username: 'ubuntu', 
  password: 'top-secret-password' 
)