direct_ssh 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +37 -6
  2. data/lib/direct_ssh/version.rb +1 -1
  3. metadata +2 -2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DirectSsh
2
2
 
3
- In order to use ssh without the need to enter password everytime, this gem will create public/private rsa keys if they do not exist and send public key to remote server
3
+ In order to use ssh without the need to enter password every time, this gem will create public/private rsa keys if they do not exist and send public key to remote server
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,11 +16,11 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install direct_ssh
18
18
 
19
- ## Usage
19
+ ## Original Style Examples
20
20
 
21
21
  Scripts like these
22
22
 
23
- a. scripts which ask password everytime
23
+ a. scripts which ask password every time
24
24
 
25
25
  ```ruby
26
26
  #!/usr/bin/env ruby
@@ -53,7 +53,9 @@ Net::SSH.start('127.0.0.1', 'user', {:password => 'password'}) { |ssh|
53
53
  }
54
54
  ```
55
55
 
56
- can be rewritten like this
56
+ can be rewritten like examples in **DirectSsh Style SSH Examples**.
57
+
58
+ ## DirectSsh Style SSH Examples
57
59
 
58
60
  c. direct_ssh example with block form
59
61
 
@@ -83,9 +85,38 @@ puts ssh.exec!('cat /etc/*-release')
83
85
  ssh.close
84
86
  ```
85
87
 
86
- ## Shell
88
+ ## DirectSsh Style SCP Examples
89
+
90
+ e. direct_ssh scp example
91
+
92
+ ```ruby
93
+ #!/usr/bin/env ruby
94
+ # encoding: UTF-8
95
+
96
+ require 'direct_ssh'
97
+ require 'net/scp'
98
+
99
+ local_path = __FILE__
100
+ file_name = File.basename(local_path)
101
+
102
+ DirectSsh.start('127.0.0.1', 'user', {:port => 22}) { |ssh|
103
+ # check whether this script file already exists on remote server
104
+ puts ssh.exec!("ls -l /tmp/#{file_name}")
105
+
106
+ # upload this script file to '/tmp' of remote server
107
+ ssh.scp.upload!(local_path, '/tmp')
108
+
109
+ # check again whether this script file already exists on remote server
110
+ puts ssh.exec!("ls -l /tmp/#{file_name}")
111
+
112
+ # download remote file and save it using another name
113
+ ssh.scp.download!("/tmp/#{file_name}", "./#{file_name}.download")
114
+ }
115
+ ```
116
+
117
+ ## Shell Commands
87
118
 
88
- The `direct_ssh` shell command checks status of ssh connection to the remote server. It will ask password and send public key to remote server if neccessary.
119
+ The `direct_ssh` shell command checks status of ssh connection to the remote server. It will ask password and send public key to remote server if necessary.
89
120
 
90
121
  After ssh connection created successfully, The `cat /etc/*-release` command will be executed.
91
122
 
@@ -1,3 +1,3 @@
1
1
  module DirectSsh
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: direct_ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-06 00:00:00.000000000 Z
12
+ date: 2013-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh