|
| 1 | +# Net::SCP |
| 2 | + |
| 3 | +***Please note: this project is in maintenance mode. It is not under active |
| 4 | +development but pull requests are very much welcome. Just be sure to include |
| 5 | +tests! -- delano*** |
| 6 | + |
| 7 | +* Docs: http://net-ssh.github.com/net-scp |
| 8 | +* Issues: https://github.com/net-ssh/net-scp/issues |
| 9 | +* Codes: https://github.com/net-ssh/net-scp |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +*As of v1.0.5, all gem releases are signed. See INSTALL.* |
| 14 | + |
| 15 | +## DESCRIPTION: |
| 16 | + |
| 17 | +Net::SCP is a pure-Ruby implementation of the SCP protocol. This operates over |
| 18 | +SSH (and requires the Net::SSH library), and allows files and directory trees |
| 19 | +to be copied to and from a remote server. |
| 20 | + |
| 21 | +## FEATURES/PROBLEMS: |
| 22 | + |
| 23 | +* Transfer files or entire directory trees to or from a remote host via SCP |
| 24 | +* Can preserve file attributes across transfers |
| 25 | +* Can download files in-memory, or direct-to-disk |
| 26 | +* Support for SCP URI's, and OpenURI |
| 27 | + |
| 28 | + |
| 29 | +## SYNOPSIS: |
| 30 | + |
| 31 | +In a nutshell: |
| 32 | + |
| 33 | + ```ruby |
| 34 | + require 'net/scp' |
| 35 | + |
| 36 | + # upload a file to a remote server |
| 37 | + Net::SCP.upload!("remote.host.com", "username", |
| 38 | + "/local/path", "/remote/path", |
| 39 | + :ssh => { :password => "password" }) |
| 40 | + |
| 41 | + # upload recursively |
| 42 | + Net::SCP.upload!("remote.host", "username", "/path/to/local", "/path/to/remote", |
| 43 | + :ssh => { :password => "foo" }, :recursive => true) |
| 44 | + |
| 45 | + # download a file from a remote server |
| 46 | + Net::SCP.download!("remote.host.com", "username", |
| 47 | + "/remote/path", "/local/path", |
| 48 | + :ssh => { :password => "password" }) |
| 49 | + |
| 50 | + # download a file to an in-memory buffer |
| 51 | + data = Net::SCP::download!("remote.host.com", "username", "/remote/path") |
| 52 | + |
| 53 | + # use a persistent connection to transfer files |
| 54 | + Net::SCP.start("remote.host.com", "username", :password => "password") do |scp| |
| 55 | + # upload a file to a remote server |
| 56 | + scp.upload! "/local/path", "/remote/path" |
| 57 | + |
| 58 | + # upload from an in-memory buffer |
| 59 | + scp.upload! StringIO.new("some data to upload"), "/remote/path" |
| 60 | + |
| 61 | + # run multiple downloads in parallel |
| 62 | + d1 = scp.download("/remote/path", "/local/path") |
| 63 | + d2 = scp.download("/remote/path2", "/local/path2") |
| 64 | + [d1, d2].each { |d| d.wait } |
| 65 | + end |
| 66 | + |
| 67 | + # You can also use open-uri to grab data via scp: |
| 68 | + require 'uri/open-scp' |
| 69 | + data = open("scp://user@host/path/to/file.txt").read |
| 70 | + ``` |
| 71 | + |
| 72 | +For more information, see Net::SCP. |
| 73 | + |
| 74 | +## REQUIREMENTS: |
| 75 | + |
| 76 | +* Net::SSH 2 |
| 77 | + |
| 78 | +If you wish to run the tests, you'll also need: |
| 79 | + |
| 80 | +* Echoe (for Rakefile use) |
| 81 | +* Mocha (for tests) |
| 82 | + |
| 83 | + |
| 84 | +## INSTALL: |
| 85 | + |
| 86 | +* ```gem install net-scp (might need sudo privileges)``` |
| 87 | + |
| 88 | + |
| 89 | +However, in order to be sure the code you're installing hasn't been tampered |
| 90 | +with, it's recommended that you verify the |
| 91 | +[signature](http://docs.seattlerb.org/rubygems/Gem/Security.html). To do this, |
| 92 | +you need to add my public key as a trusted certificate (you only need to do |
| 93 | +this once): |
| 94 | + |
| 95 | + ```sh |
| 96 | + # Add the public key as a trusted certificate |
| 97 | + # (You only need to do this once) |
| 98 | + $ curl -O https://raw.githubusercontent.com/net-ssh/net-ssh/master/net-ssh-public_cert.pem |
| 99 | + $ gem cert --add net-ssh-public_cert.pem |
| 100 | + ``` |
| 101 | + |
| 102 | +Then- when installing the gem - do so with high security: |
| 103 | + |
| 104 | + `$ gem install net-scp -P HighSecurity` |
| 105 | + |
| 106 | +If you don't add the public key, you'll see an error like "Couldn't verify |
| 107 | +data signature". If you're still having trouble let me know and I'll give you |
| 108 | +a hand. |
| 109 | + |
| 110 | +Or, you can do it the hard way (without Rubygems): |
| 111 | + |
| 112 | +* tar xzf net-scp-*.tgz |
| 113 | +* cd net-scp-* |
| 114 | +* ruby setup.rb config |
| 115 | +* ruby setup.rb install (might need sudo privileges) |
| 116 | + |
| 117 | + |
| 118 | +## LICENSE: |
| 119 | + |
| 120 | +(The MIT License) |
| 121 | + |
| 122 | +Copyright (c) 2008 Jamis Buck <[email protected]> |
| 123 | + |
| 124 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 125 | +of this software and associated documentation files (the 'Software'), to deal |
| 126 | +in the Software without restriction, including without limitation the rights |
| 127 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 128 | +copies of the Software, and to permit persons to whom the Software is |
| 129 | +furnished to do so, subject to the following conditions: |
| 130 | + |
| 131 | +The above copyright notice and this permission notice shall be included in all |
| 132 | +copies or substantial portions of the Software. |
| 133 | + |
| 134 | +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 135 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 136 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 137 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 138 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 139 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 140 | +SOFTWARE. |
0 commit comments