[Ruby]Base64エンコードされたデータをSCPでアップロードする ref: https://qiita.com/kitaro_tn/items/01a498e4e4a2672e991d
# coding: utf-8
require 'tempfile'
require 'net/scp'
require 'base64'
contents = Base64.encode64("contents")
save_path = "/var/tmp/test.txt"
host = "localhost"
user = "username"
password = ""
Tempfile.create("upload") do |tf|
tf.binmode
tf.write(Base64.decode64(contents))
tf.rewind
file_size = tf.size
Net::SCP.start(host, user,
password: password) do |scp|
scp.upload! tf.path, save_path
end
end
$ gem install net-scp