4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Specinfra経由でSSHする

Posted at
require 'specinfra'

Specinfra.configuration.backend = :ssh
Specinfra.configuration.host = 'sample.udzura.jp'
Specinfra.configuration.ssh_options = {user: 'udzura', keys: '/Users/udzura/.ssh/udzura.pem'}
Specinfra.configuration.request_pty = true

Specinfra.backend
#=> #<Specinfra::Backend::Ssh:0x007fd10b9c4418 @config={}>

cmd = Specinfra::Runner.run_command('whoami')
#=> #<Specinfra::CommandResult:0x007fd10bb352e8 @stdout="root\n", @stderr="", @exit_status=0, @exit_signal=nil>
puts cmd.stdout
# root
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?