tinyssh is a little ruby script to batch execute command, upload/download file or directory with ssh
Require
you should have ruby installed and some support packages for ssh
- ruby
- rubygems
- net-ssh
- net-scp
- highline
you can install them by follow command if you use RPM base Linux
yum -y install ruby rubygems
gem install net-ssh
gem install net-scp
gem install highline
gem install tinyssh
Usage
Usage: ruby tinyssh.rb run|upload|download <position parameters> [option]
Specific options:
-u, --user [user] Specify a user for accessing remote hosts.(default: root)
-p, --port [port] Port to connect to on the remote host(default: 22)
-t, --timeout [time] Set the command timeout to seconds(default: 0)
-l, --list-file [file] File containing a list of hosts' IP Address
-o, --output-file [file] Output result to log file
-i, --identity-key [key] identity (private) key for authentication(default: /root/.ssh/id_rsa)
-n, --number-of-thread [number] Specify the number of concurrent jobs for each execution
-h, --help Show this message
- Run command
ruby tinyssh.rb run "command" -l my_host.txt -u root -p 22 -t 10 -i my_keys -n 10
- Upload file or directory
ruby tinyssh.rb upload src_file_or_directory dst_directory -l my_host.txt -u root -p 22 -t 10 -i my_keys -n 10
- Download file or directory
ruby tinyssh.rb download src_file_or_directory dst_directory -l my_host.txt -u root -p 22 -t 10 -i my_keys -n 10
Note: run
, upload
, download
, can be r
, u
, d
Note: if you use key to authorize and your key is /root/.ssh/id_rsa
, you don't need to specify -i /root/.ssh/id_rsa
, but it will ask for password, just press enter