ruby の net-ssh-shell を使う net-ssh version 2 だと環境変数の設定ができなくて困った。 https://github.com/mitchellh/net-ssh-shell を使って bash を動かせば普段、ssh を使うような感覚で使用することができる。 インストール gem install net-ssh-shell で良いのだが、github にある最新のバージョンを使うには git clone https://github.com/mitchellh/net-ssh-shell.git を実行して取得したファイルに gem のファイルを置き換える。 使い方 Net::SSH.start('host', 'user') do |ssh| ssh.shell do |sh| sh.execute "ls" sh.execute "exit" en