Upload a file to a remote server in ruby.
require 'kanrisuru' host = Kanrisuru::Remote::Host.new(host: 'centos-host', username: 'centos', keys: ['~/.ssh/id_rsa']) result = host.upload("~/projects/kanrisuru/certs", '/etc/nginx/ssl/certs', recursive: true) result.success? true result.path '/etc/nginx/ssl/certs'
This command might need escalated privlidges to access certain files that have file permissions set for root access.
||Required path on local machine to upload a file / directory.|
||Path on remote machine to upload file or directory to.|
||Should upload a remote directory and recursively upload all of it's subdirectories|
Returns a single
||The mode bits set for the file / directory.|
||The number of blocks allocated for the file.|
||The major and minor device number combined into one value (in hex and decimal) of the device on which the file resides.|
||What's the file type, ie: directory, file, block_device, char_device, symlink|
||The group id in which the file belongs to.|
||The group name in which the file belongs to.|
||Number of hard links pointing to the underlying inode.|
||Unique inode value assigned to the file|
||Where is the file located at|
||Size of the file (in bytes)|
||The user id that owns the file|
||The user that owns the file|
||When was the last time the file was accessed.|
||When was the last time the file was updated.|
||When was the last time the file was changed.|
host.upload('~/files', '/home/ubuntu/files', recursive: true).data #<Struct:Kanrisuru::Core::Stat::FileStat:0x00000668 attr_reader :size = 4096, blocks = 8, device = "fc01", file_type = "directory", gid = 1000, group = "ubuntu", inode = 1552072, last_access = #<DateTime: 2022-01-08T11:15:50-06:00 ((2459588j,62150s,911827766n),-21600s,2299161j)>, last_changed = #<DateTime: 2022-01-08T11:15:50-06:00 ((2459588j,62150s,991826940n),-21600s,2299161j)>, last_modified = #<DateTime: 2022-01-08T11:15:50-06:00 ((2459588j,62150s,991826940n),-21600s,2299161j)>, links = 2, mode = #<Kanrisuru::Mode:0x800 @numeric=775 @symbolic=drwxrwxr-x>, path = "/home/ubuntu/files", uid = 1000, user = "ubuntu" >
- Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES