My Daily Technical Notes [ Ruby, Rails, Gems, Server Ops]

SSHKit is an amazing tool to run any commands on your VPS or docker images as any user. Capistrano uses it to all the server related stuffs. In other words you can build your own deployer software or server maintenance tools using SSHKit.

$ gem install sshkit

Simple Introduction

Lets create a ruby script to create a file in my VPS’s home directory

require 'sshkit'
require 'sshkit/dsl'
on ['deployer@4X.79.XXX.XX1'], in: :sequence, wait: 1 do |host|
  within '~' do # or '/home/deployer/'as :deployer doexecute 'echo', 'My name is shiva > shiva.txt'
    endendend

Go and check in your VPS, you see the file

View original post 285 more words

Advertisements