net-ssh 5.2.0 → 7.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.dockerignore +6 -0
- data/.github/config/rubocop_linter_action.yml +4 -0
- data/.github/workflows/ci-with-docker.yml +44 -0
- data/.github/workflows/ci.yml +87 -0
- data/.github/workflows/rubocop.yml +13 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +16 -2
- data/.rubocop_todo.yml +623 -511
- data/CHANGES.txt +50 -2
- data/Dockerfile +27 -0
- data/Dockerfile.openssl3 +17 -0
- data/Gemfile +2 -0
- data/Gemfile.noed25519 +2 -0
- data/Manifest +0 -1
- data/README.md +293 -0
- data/Rakefile +6 -2
- data/appveyor.yml +4 -2
- data/docker-compose.yml +23 -0
- data/lib/net/ssh/authentication/agent.rb +29 -13
- data/lib/net/ssh/authentication/certificate.rb +19 -7
- data/lib/net/ssh/authentication/constants.rb +0 -1
- data/lib/net/ssh/authentication/ed25519.rb +13 -8
- data/lib/net/ssh/authentication/ed25519_loader.rb +5 -8
- data/lib/net/ssh/authentication/key_manager.rb +73 -32
- data/lib/net/ssh/authentication/methods/abstract.rb +12 -3
- data/lib/net/ssh/authentication/methods/hostbased.rb +3 -5
- data/lib/net/ssh/authentication/methods/keyboard_interactive.rb +5 -3
- data/lib/net/ssh/authentication/methods/none.rb +6 -9
- data/lib/net/ssh/authentication/methods/password.rb +2 -3
- data/lib/net/ssh/authentication/methods/publickey.rb +56 -16
- data/lib/net/ssh/authentication/pageant.rb +97 -97
- data/lib/net/ssh/authentication/pub_key_fingerprint.rb +2 -3
- data/lib/net/ssh/authentication/session.rb +27 -23
- data/lib/net/ssh/buffer.rb +51 -40
- data/lib/net/ssh/buffered_io.rb +24 -26
- data/lib/net/ssh/config.rb +82 -50
- data/lib/net/ssh/connection/channel.rb +101 -87
- data/lib/net/ssh/connection/constants.rb +0 -4
- data/lib/net/ssh/connection/event_loop.rb +30 -25
- data/lib/net/ssh/connection/keepalive.rb +12 -12
- data/lib/net/ssh/connection/session.rb +115 -111
- data/lib/net/ssh/connection/term.rb +56 -58
- data/lib/net/ssh/errors.rb +12 -12
- data/lib/net/ssh/key_factory.rb +10 -13
- data/lib/net/ssh/known_hosts.rb +106 -39
- data/lib/net/ssh/loggable.rb +10 -11
- data/lib/net/ssh/packet.rb +1 -1
- data/lib/net/ssh/prompt.rb +9 -11
- data/lib/net/ssh/proxy/command.rb +1 -2
- data/lib/net/ssh/proxy/errors.rb +2 -4
- data/lib/net/ssh/proxy/http.rb +18 -20
- data/lib/net/ssh/proxy/https.rb +8 -10
- data/lib/net/ssh/proxy/jump.rb +8 -10
- data/lib/net/ssh/proxy/socks4.rb +2 -4
- data/lib/net/ssh/proxy/socks5.rb +3 -6
- data/lib/net/ssh/service/forward.rb +9 -8
- data/lib/net/ssh/test/channel.rb +24 -26
- data/lib/net/ssh/test/extensions.rb +35 -35
- data/lib/net/ssh/test/kex.rb +6 -8
- data/lib/net/ssh/test/local_packet.rb +0 -2
- data/lib/net/ssh/test/packet.rb +3 -3
- data/lib/net/ssh/test/remote_packet.rb +6 -8
- data/lib/net/ssh/test/script.rb +25 -27
- data/lib/net/ssh/test/socket.rb +12 -15
- data/lib/net/ssh/test.rb +7 -7
- data/lib/net/ssh/transport/algorithms.rb +100 -58
- data/lib/net/ssh/transport/cipher_factory.rb +34 -50
- data/lib/net/ssh/transport/constants.rb +13 -9
- data/lib/net/ssh/transport/ctr.rb +8 -14
- data/lib/net/ssh/transport/hmac/abstract.rb +20 -5
- data/lib/net/ssh/transport/hmac/md5.rb +0 -2
- data/lib/net/ssh/transport/hmac/md5_96.rb +0 -2
- data/lib/net/ssh/transport/hmac/none.rb +0 -2
- data/lib/net/ssh/transport/hmac/ripemd160.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha1.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha1_96.rb +0 -2
- data/lib/net/ssh/transport/hmac/sha2_256.rb +7 -11
- data/lib/net/ssh/transport/hmac/sha2_256_96.rb +4 -8
- data/lib/net/ssh/transport/hmac/sha2_256_etm.rb +12 -0
- data/lib/net/ssh/transport/hmac/sha2_512.rb +6 -9
- data/lib/net/ssh/transport/hmac/sha2_512_96.rb +4 -8
- data/lib/net/ssh/transport/hmac/sha2_512_etm.rb +12 -0
- data/lib/net/ssh/transport/hmac.rb +13 -11
- data/lib/net/ssh/transport/identity_cipher.rb +11 -13
- data/lib/net/ssh/transport/kex/abstract.rb +130 -0
- data/lib/net/ssh/transport/kex/abstract5656.rb +72 -0
- data/lib/net/ssh/transport/kex/curve25519_sha256.rb +39 -0
- data/lib/net/ssh/transport/kex/curve25519_sha256_loader.rb +30 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +5 -19
- data/lib/net/ssh/transport/kex/diffie_hellman_group14_sha256.rb +11 -0
- data/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +30 -139
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +1 -8
- data/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +5 -9
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +20 -81
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +5 -4
- data/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +5 -4
- data/lib/net/ssh/transport/kex.rb +15 -10
- data/lib/net/ssh/transport/key_expander.rb +7 -8
- data/lib/net/ssh/transport/openssl.rb +149 -127
- data/lib/net/ssh/transport/packet_stream.rb +50 -16
- data/lib/net/ssh/transport/server_version.rb +17 -16
- data/lib/net/ssh/transport/session.rb +9 -7
- data/lib/net/ssh/transport/state.rb +44 -44
- data/lib/net/ssh/verifiers/accept_new.rb +0 -2
- data/lib/net/ssh/verifiers/accept_new_or_local_tunnel.rb +1 -2
- data/lib/net/ssh/verifiers/always.rb +6 -4
- data/lib/net/ssh/verifiers/never.rb +0 -2
- data/lib/net/ssh/version.rb +3 -3
- data/lib/net/ssh.rb +12 -8
- data/net-ssh-public_cert.pem +8 -8
- data/net-ssh.gemspec +9 -7
- data/support/ssh_tunnel_bug.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +55 -30
- metadata.gz.sig +0 -0
- data/.travis.yml +0 -53
- data/Gemfile.noed25519.lock +0 -41
- data/README.rdoc +0 -194
- data/lib/net/ssh/ruby_compat.rb +0 -13
- data/support/arcfour_check.rb +0 -20
data/CHANGES.txt
CHANGED
@@ -1,7 +1,55 @@
|
|
1
|
+
=== 6.3.0 beta1
|
2
|
+
|
3
|
+
* Support cert based host key auth, fix asterisk in known_hosts [#833]
|
4
|
+
* Support kex dh-group14-sha256 [#795]
|
5
|
+
* Fix StrictHostKeyChecking ssh config parameter translation [#765]
|
6
|
+
|
7
|
+
=== 6.2.0 rc1
|
8
|
+
|
9
|
+
=== 6.2.0 beta1
|
10
|
+
|
11
|
+
* rsa-sha2-512, rsa-sha2-256 host_key algs [#771]
|
12
|
+
* JRuby aes*-ctr suppport [#767]
|
13
|
+
|
14
|
+
=== 6.1.0
|
15
|
+
|
16
|
+
* Adapt to ssh's default behaviors when no username is provided.
|
17
|
+
When Net::SSH.start user is nil and config has no entry
|
18
|
+
we default to Etc.getpwuid.name() instead of Etc.getlogin(). [#749]
|
19
|
+
|
20
|
+
=== 6.1.0.rc1
|
21
|
+
|
22
|
+
* Make sha2-{256,512}-etm@openssh.com MAC default again [#761]
|
23
|
+
* Support algorithm subtraction syntax from ssh_config [#751]
|
24
|
+
|
25
|
+
=== 6.0.2
|
26
|
+
|
27
|
+
* Fix corrupted hmac issue in etm hmac [#759]
|
28
|
+
|
29
|
+
=== 6.0.1
|
30
|
+
|
31
|
+
* Make sha2-{256,512}-etm@openssh.com MAC opt-in as they seems to have issues [#757]
|
32
|
+
|
33
|
+
=== 6.0.0
|
34
|
+
|
35
|
+
* Support empty lines and comments in known_hosts [donoghuc, #742]
|
36
|
+
* Add sha2-{256,512}-etm@openssh.com MAC algorithms [graaff, #714]
|
37
|
+
|
38
|
+
=== 6.0.0 beta2
|
39
|
+
|
40
|
+
* Support :certkeys and CertificateFile configuration option [Anders Carling, #722]
|
41
|
+
|
42
|
+
=== 6.0.0 beta1
|
43
|
+
|
44
|
+
* curve25519sha256 support [Florian Wininger ,#690]
|
45
|
+
* disabled insecure algs [Florian Wininger , #709]
|
46
|
+
|
47
|
+
=== 5.2.0
|
48
|
+
|
1
49
|
=== 5.2.0.rc3
|
2
50
|
|
3
51
|
* Fix check_host_ip read from config
|
4
|
-
* Support ssh-ed25519 in
|
52
|
+
* Support ssh-ed25519 in known hosts
|
5
53
|
|
6
54
|
=== 5.2.0.rc2
|
7
55
|
|
@@ -24,7 +72,7 @@
|
|
24
72
|
|
25
73
|
=== 5.0.2
|
26
74
|
|
27
|
-
*
|
75
|
+
* Fix ctr for jruby [#612]
|
28
76
|
|
29
77
|
=== 5.0.1
|
30
78
|
|
data/Dockerfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
ARG RUBY_VERSION=3.1
|
2
|
+
FROM ruby:${RUBY_VERSION}
|
3
|
+
|
4
|
+
RUN apt update && apt install -y openssh-server sudo netcat \
|
5
|
+
&& useradd --create-home --shell '/bin/bash' --comment 'NetSSH' 'net_ssh_1' \
|
6
|
+
&& useradd --create-home --shell '/bin/bash' --comment 'NetSSH' 'net_ssh_2' \
|
7
|
+
&& echo net_ssh_1:foopwd | chpasswd \
|
8
|
+
&& echo net_ssh_2:foo2pwd | chpasswd \
|
9
|
+
&& mkdir -p /home/net_ssh_1/.ssh \
|
10
|
+
&& mkdir -p /home/net_ssh_2/.ssh \
|
11
|
+
&& echo "net_ssh_1 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
|
12
|
+
&& echo "net_ssh_2 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
|
13
|
+
&& ssh-keygen -f /etc/ssh/users_ca -N ''
|
14
|
+
|
15
|
+
ENV INSTALL_PATH="/netssh"
|
16
|
+
|
17
|
+
WORKDIR $INSTALL_PATH
|
18
|
+
|
19
|
+
COPY Gemfile net-ssh.gemspec $INSTALL_PATH/
|
20
|
+
|
21
|
+
COPY lib/net/ssh/version.rb $INSTALL_PATH/lib/net/ssh/version.rb
|
22
|
+
|
23
|
+
RUN gem install bundler && bundle install
|
24
|
+
|
25
|
+
COPY . $INSTALL_PATH/
|
26
|
+
|
27
|
+
CMD service ssh start && rake test && NET_SSH_NO_ED25519=1 rake test
|
data/Dockerfile.openssl3
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
FROM ubuntu:22.04
|
2
|
+
|
3
|
+
ENV INSTALL_PATH="/netssh"
|
4
|
+
|
5
|
+
RUN apt update && apt install -y openssl ruby ruby-dev git build-essential
|
6
|
+
|
7
|
+
WORKDIR $INSTALL_PATH
|
8
|
+
|
9
|
+
COPY Gemfile net-ssh.gemspec $INSTALL_PATH/
|
10
|
+
|
11
|
+
COPY lib/net/ssh/version.rb $INSTALL_PATH/lib/net/ssh/version.rb
|
12
|
+
|
13
|
+
RUN ls -l && gem install bundler && bundle install
|
14
|
+
|
15
|
+
COPY . $INSTALL_PATH/
|
16
|
+
|
17
|
+
CMD openssl version && ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION' && rake test
|
data/Gemfile
CHANGED
data/Gemfile.noed25519
CHANGED
data/Manifest
CHANGED
data/README.md
ADDED
@@ -0,0 +1,293 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/net-ssh.svg)](https://badge.fury.io/rb/net-ssh)
|
2
|
+
[![Join the chat at https://gitter.im/net-ssh/net-ssh](https://badges.gitter.im/net-ssh/net-ssh.svg)](https://gitter.im/net-ssh/net-ssh?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
3
|
+
[![Build status](https://github.com/net-ssh/net-ssh/actions/workflows/ci.yml/badge.svg)](https://github.com/net-ssh/net-ssh/actions/workflows/ci.yml)
|
4
|
+
[![Coverage status](https://codecov.io/gh/net-ssh/net-ssh/branch/master/graph/badge.svg)](https://codecov.io/gh/net-ssh/net-ssh)
|
5
|
+
[![Backers on Open Collective](https://opencollective.com/net-ssh/backers/badge.svg)](#backers])
|
6
|
+
[![Sponsors on Open Collective](https://opencollective.com/net-ssh/sponsors/badge.svg)](#sponsors)
|
7
|
+
|
8
|
+
# Net::SSH 6.x
|
9
|
+
|
10
|
+
* Docs: http://net-ssh.github.io/net-ssh
|
11
|
+
* Issues: https://github.com/net-ssh/net-ssh/issues
|
12
|
+
* Codes: https://github.com/net-ssh/net-ssh
|
13
|
+
* Email: net-ssh@solutious.com
|
14
|
+
|
15
|
+
*As of v2.6.4, all gem releases are signed. See [INSTALL](#install).*
|
16
|
+
|
17
|
+
## DESCRIPTION:
|
18
|
+
|
19
|
+
Net::SSH is a pure-Ruby implementation of the SSH2 client protocol.
|
20
|
+
It allows you to write programs that invoke and interact with processes on remote servers, via SSH2.
|
21
|
+
|
22
|
+
## FEATURES:
|
23
|
+
|
24
|
+
* Execute processes on remote servers and capture their output
|
25
|
+
* Run multiple processes in parallel over a single SSH connection
|
26
|
+
* Support for SSH subsystems
|
27
|
+
* Forward local and remote ports via an SSH connection
|
28
|
+
|
29
|
+
## Supported Algorithms
|
30
|
+
|
31
|
+
Net::SSH 6.0 disables by default the usage of weak algorithms.
|
32
|
+
We strongly recommend that you install a servers's version that supports the latest algorithms.
|
33
|
+
|
34
|
+
It is possible to return to the previous behavior by adding the option : `append_all_supported_algorithms: true`
|
35
|
+
|
36
|
+
Unsecure algoritms will definitely be removed in Net::SSH 7.*.
|
37
|
+
|
38
|
+
### Host Keys
|
39
|
+
|
40
|
+
| Name | Support | Details |
|
41
|
+
|----------------------|-----------------------|----------|
|
42
|
+
| ssh-rsa | OK | |
|
43
|
+
| ssh-ed25519 | OK | Require the gem `ed25519` |
|
44
|
+
| ecdsa-sha2-nistp521 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
|
45
|
+
| ecdsa-sha2-nistp384 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
|
46
|
+
| ecdsa-sha2-nistp256 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
|
47
|
+
| ssh-dss | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
48
|
+
|
49
|
+
### Key Exchange
|
50
|
+
|
51
|
+
| Name | Support | Details |
|
52
|
+
|--------------------------------------|-----------------------|----------|
|
53
|
+
| curve25519-sha256 | OK | Require the gem `x25519` |
|
54
|
+
| ecdh-sha2-nistp521 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
|
55
|
+
| ecdh-sha2-nistp384 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
|
56
|
+
| ecdh-sha2-nistp256 | OK | [using weak elliptic curves](https://safecurves.cr.yp.to/) |
|
57
|
+
| diffie-hellman-group1-sha1 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
58
|
+
| diffie-hellman-group14-sha1 | OK | |
|
59
|
+
| diffie-hellman-group-exchange-sha1 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
60
|
+
| diffie-hellman-group-exchange-sha256 | OK | |
|
61
|
+
|
62
|
+
### Encryption algorithms (ciphers)
|
63
|
+
|
64
|
+
| Name | Support | Details |
|
65
|
+
|--------------------------------------|-----------------------|----------|
|
66
|
+
| aes256-ctr / aes192-ctr / aes128-ctr | OK | |
|
67
|
+
| aes256-cbc / aes192-cbc / aes128-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
68
|
+
| rijndael-cbc@lysator.liu.se | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
69
|
+
| blowfish-ctr blowfish-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
70
|
+
| cast128-ctr cast128-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
71
|
+
| 3des-ctr 3des-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
72
|
+
| idea-cbc | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
73
|
+
| none | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
74
|
+
|
75
|
+
### Message Authentication Code algorithms
|
76
|
+
|
77
|
+
| Name | Support | Details |
|
78
|
+
|----------------------|-----------------------|----------|
|
79
|
+
| hmac-sha2-512-etm | OK | |
|
80
|
+
| hmac-sha2-256-etm | OK | |
|
81
|
+
| hmac-sha2-512 | OK | |
|
82
|
+
| hmac-sha2-256 | OK | |
|
83
|
+
| hmac-sha2-512-96 | Deprecated in 6.0 | removed from the specification, will be removed in 7.0 |
|
84
|
+
| hmac-sha2-256-96 | Deprecated in 6.0 | removed from the specification, will be removed in 7.0 |
|
85
|
+
| hmac-sha1 | OK | for backward compatibility |
|
86
|
+
| hmac-sha1-96 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
87
|
+
| hmac-ripemd160 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
88
|
+
| hmac-md5 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
89
|
+
| hmac-md5-96 | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
90
|
+
| none | Deprecated in 6.0 | unsecure, will be removed in 7.0 |
|
91
|
+
|
92
|
+
## SYNOPSIS:
|
93
|
+
|
94
|
+
In a nutshell:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
require 'net/ssh'
|
98
|
+
|
99
|
+
Net::SSH.start('host', 'user', password: "password") do |ssh|
|
100
|
+
|
101
|
+
# capture all stderr and stdout output from a remote process
|
102
|
+
output = ssh.exec!("hostname")
|
103
|
+
puts output
|
104
|
+
|
105
|
+
# capture only stdout matching a particular pattern
|
106
|
+
stdout = ""
|
107
|
+
ssh.exec!("ls -l /home/jamis") do |channel, stream, data|
|
108
|
+
stdout << data if stream == :stdout && /foo/.match(data)
|
109
|
+
end
|
110
|
+
puts stdout
|
111
|
+
|
112
|
+
# run multiple processes in parallel to completion
|
113
|
+
ssh.exec "sed ..."
|
114
|
+
ssh.exec "awk ..."
|
115
|
+
ssh.exec "rm -rf ..."
|
116
|
+
ssh.loop
|
117
|
+
|
118
|
+
# open a new channel and configure a minimal set of callbacks, then run
|
119
|
+
# the event loop until the channel finishes (closes)
|
120
|
+
channel = ssh.open_channel do |ch|
|
121
|
+
ch.exec "/usr/local/bin/ruby /path/to/file.rb" do |ch, success|
|
122
|
+
raise "could not execute command" unless success
|
123
|
+
|
124
|
+
# "on_data" is called when the process writes something to stdout
|
125
|
+
ch.on_data do |c, data|
|
126
|
+
$stdout.print data
|
127
|
+
end
|
128
|
+
|
129
|
+
# "on_extended_data" is called when the process writes something to stderr
|
130
|
+
ch.on_extended_data do |c, type, data|
|
131
|
+
$stderr.print data
|
132
|
+
end
|
133
|
+
|
134
|
+
ch.on_close { puts "done!" }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
channel.wait
|
139
|
+
|
140
|
+
# forward connections on local port 1234 to port 80 of www.capify.org
|
141
|
+
ssh.forward.local(1234, "www.capify.org", 80)
|
142
|
+
ssh.loop { true }
|
143
|
+
end
|
144
|
+
```
|
145
|
+
|
146
|
+
See Net::SSH for more documentation, and links to further information.
|
147
|
+
|
148
|
+
## REQUIREMENTS:
|
149
|
+
|
150
|
+
The only requirement you might be missing is the OpenSSL bindings for Ruby with a version greather than `1.0.1`.
|
151
|
+
These are built by default on most platforms, but you can verify that they're built and installed on your system by running the following command line:
|
152
|
+
|
153
|
+
```sh
|
154
|
+
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
|
155
|
+
```
|
156
|
+
|
157
|
+
If that spits out something like `OpenSSL 1.0.1 14 Mar 2012`, then you're set.
|
158
|
+
If you get an error, then you'll need to see about rebuilding ruby with OpenSSL support,
|
159
|
+
or (if your platform supports it) installing the OpenSSL bindings separately.
|
160
|
+
|
161
|
+
## INSTALL:
|
162
|
+
|
163
|
+
```sh
|
164
|
+
gem install net-ssh # might need sudo privileges
|
165
|
+
```
|
166
|
+
|
167
|
+
NOTE: If you are running on jruby on windows you need to install `jruby-pageant` manually
|
168
|
+
(gemspec doesn't allow for platform specific dependencies at gem installation time).
|
169
|
+
|
170
|
+
However, in order to be sure the code you're installing hasn't been tampered with,
|
171
|
+
it's recommended that you verify the [signature](http://docs.rubygems.org/read/chapter/21).
|
172
|
+
To do this, you need to add my public key as a trusted certificate (you only need to do this once):
|
173
|
+
|
174
|
+
```sh
|
175
|
+
# Add the public key as a trusted certificate
|
176
|
+
# (You only need to do this once)
|
177
|
+
curl -O https://raw.githubusercontent.com/net-ssh/net-ssh/master/net-ssh-public_cert.pem
|
178
|
+
gem cert --add net-ssh-public_cert.pem
|
179
|
+
```
|
180
|
+
|
181
|
+
Then, when install the gem, do so with high security:
|
182
|
+
|
183
|
+
```sh
|
184
|
+
gem install net-ssh -P HighSecurity
|
185
|
+
```
|
186
|
+
|
187
|
+
If you don't add the public key, you'll see an error like "Couldn't verify data signature".
|
188
|
+
If you're still having trouble let me know and I'll give you a hand.
|
189
|
+
|
190
|
+
For ed25519 public key auth support your bundle file should contain `ed25519`, `bcrypt_pbkdf` dependencies.
|
191
|
+
|
192
|
+
```sh
|
193
|
+
gem install ed25519
|
194
|
+
gem install bcrypt_pbkdf
|
195
|
+
```
|
196
|
+
|
197
|
+
For curve25519-sha256 kex exchange support your bundle file should contain `x25519` dependency.
|
198
|
+
|
199
|
+
## RUBY SUPPORT
|
200
|
+
|
201
|
+
* See [net-ssh.gemspec](https://github.com/net-ssh/net-ssh/blob/master/net-ssh.gemspec) for current versions ruby requirements
|
202
|
+
|
203
|
+
## RUNNING TESTS
|
204
|
+
|
205
|
+
If you want to run the tests or use any of the Rake tasks, you'll need Mocha and
|
206
|
+
other dependencies listed in Gemfile
|
207
|
+
|
208
|
+
Run the test suite from the net-ssh directory with the following command:
|
209
|
+
|
210
|
+
```sh
|
211
|
+
bundle exec rake test
|
212
|
+
```
|
213
|
+
|
214
|
+
NOTE : you can run test on all ruby versions with docker :
|
215
|
+
|
216
|
+
```
|
217
|
+
docker-compose up --build
|
218
|
+
```
|
219
|
+
|
220
|
+
Run a single test file like this:
|
221
|
+
|
222
|
+
```sh
|
223
|
+
ruby -Ilib -Itest test/transport/test_server_version.rb
|
224
|
+
```
|
225
|
+
|
226
|
+
To run integration tests see [here](test/integration/README.md)
|
227
|
+
|
228
|
+
### BUILDING GEM
|
229
|
+
|
230
|
+
```sh
|
231
|
+
rake build
|
232
|
+
```
|
233
|
+
|
234
|
+
### GEM SIGNING (for maintainers)
|
235
|
+
|
236
|
+
If you have the net-ssh private signing key, you will be able to create signed release builds. Make sure the private key path matches the `signing_key` path set in `net-ssh.gemspec` and tell rake to sign the gem by setting the `NET_SSH_BUILDGEM_SIGNED` flag:
|
237
|
+
|
238
|
+
```sh
|
239
|
+
NET_SSH_BUILDGEM_SIGNED=true rake build
|
240
|
+
```
|
241
|
+
|
242
|
+
For time to time, the public certificate associated to the private key needs to be renewed. You can do this with the following command:
|
243
|
+
|
244
|
+
```sh
|
245
|
+
gem cert --build netssh@solutious.com --private-key path/2/net-ssh-private_key.pem
|
246
|
+
mv gem-public_cert.pem net-ssh-public_cert.pem
|
247
|
+
gem cert --add net-ssh-public_cert.pem
|
248
|
+
```
|
249
|
+
|
250
|
+
## CREDITS
|
251
|
+
|
252
|
+
### Contributors
|
253
|
+
|
254
|
+
This project exists thanks to all the people who contribute.
|
255
|
+
|
256
|
+
[![contributors](https://opencollective.com/net-ssh/contributors.svg?width=890&button=false)](graphs/contributors)
|
257
|
+
|
258
|
+
### Backers
|
259
|
+
|
260
|
+
Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/net-ssh#backer)
|
261
|
+
|
262
|
+
[![backers](https://opencollective.com/net-ssh/backers.svg?width=890)](https://opencollective.com/net-ssh#backers)
|
263
|
+
|
264
|
+
### Sponsors
|
265
|
+
|
266
|
+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](https://opencollective.com/net-ssh#sponsor)
|
267
|
+
|
268
|
+
[![Sponsor](https://opencollective.com/net-ssh/sponsor/0/avatar.svg)](https://opencollective.com/net-ssh/sponsor/0/website)
|
269
|
+
|
270
|
+
## LICENSE:
|
271
|
+
|
272
|
+
(The MIT License)
|
273
|
+
|
274
|
+
Copyright (c) 2008 Jamis Buck
|
275
|
+
|
276
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
277
|
+
a copy of this software and associated documentation files (the
|
278
|
+
'Software'), to deal in the Software without restriction, including
|
279
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
280
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
281
|
+
permit persons to whom the Software is furnished to do so, subject to
|
282
|
+
the following conditions:
|
283
|
+
|
284
|
+
The above copyright notice and this permission notice shall be
|
285
|
+
included in all copies or substantial portions of the Software.
|
286
|
+
|
287
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
288
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
289
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
290
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
291
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
292
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
293
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
#
|
3
2
|
# Also in your terminal environment run:
|
4
3
|
# $ export LANG=en_US.UTF-8
|
@@ -32,7 +31,7 @@ RDoc::Task.new do |rdoc|
|
|
32
31
|
rdoc.rdoc_dir = "rdoc"
|
33
32
|
rdoc.title = "#{name} #{version}"
|
34
33
|
rdoc.generator = 'hanna' # gem install hanna-nouveau
|
35
|
-
rdoc.main = 'README.
|
34
|
+
rdoc.main = 'README.md'
|
36
35
|
rdoc.rdoc_files.include("README*")
|
37
36
|
rdoc.rdoc_files.include("bin/*.rb")
|
38
37
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
@@ -49,6 +48,7 @@ namespace :cert do
|
|
49
48
|
raw = File.read "net-ssh-public_cert.pem"
|
50
49
|
certificate = OpenSSL::X509::Certificate.new raw
|
51
50
|
raise Exception, "Not yet expired: #{certificate.not_after}" unless certificate.not_after < Time.now
|
51
|
+
|
52
52
|
sh "gem cert --build netssh@solutious.com --days 365*5 --private-key /mnt/gem/net-ssh-private_key.pem"
|
53
53
|
sh "mv gem-public_cert.pem net-ssh-public_cert.pem"
|
54
54
|
sh "gem cert --add net-ssh-public_cert.pem"
|
@@ -95,6 +95,10 @@ Rake::TestTask.new do |t|
|
|
95
95
|
t.test_files = test_files
|
96
96
|
end
|
97
97
|
|
98
|
+
# We need to enable the OpenSSL 3.0 legacy providers for our test suite
|
99
|
+
require 'openssl'
|
100
|
+
ENV['OPENSSL_CONF'] = 'test/openssl3.conf' if OpenSSL::OPENSSL_LIBRARY_VERSION.start_with? "OpenSSL 3"
|
101
|
+
|
98
102
|
desc "Run tests of Net::SSH:Test"
|
99
103
|
Rake::TestTask.new do |t|
|
100
104
|
t.name = "test_test"
|
data/appveyor.yml
CHANGED
@@ -5,9 +5,11 @@ skip_tags: true
|
|
5
5
|
environment:
|
6
6
|
matrix:
|
7
7
|
- ruby_version: "jruby-9.1.2.0"
|
8
|
+
- ruby_version: "26-x64"
|
9
|
+
- ruby_version: "25-x64"
|
10
|
+
- ruby_version: "24-x64"
|
8
11
|
- ruby_version: "23"
|
9
12
|
- ruby_version: "23-x64"
|
10
|
-
- ruby_version: "22-x64"
|
11
13
|
|
12
14
|
matrix:
|
13
15
|
allow_failures:
|
@@ -29,7 +31,7 @@ install:
|
|
29
31
|
- if "%ruby_version%" == "jruby-9.1.2.0" ( cinst jruby --version 9.1.2.0 -i --allow-empty-checksums )
|
30
32
|
- if "%ruby_version%" == "jruby-9.1.2.0" ( SET "PATH=C:\jruby-9.1.2.0\bin\;%PATH%" )
|
31
33
|
- ruby --version
|
32
|
-
- gem install bundler --no-document --user-install -v 1.
|
34
|
+
- gem install bundler --no-document --user-install -v 1.17
|
33
35
|
- SET BUNDLE_GEMFILE=Gemfile.noed25519
|
34
36
|
- bundle install --retry=3
|
35
37
|
- cinst freesshd
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
version: '3'
|
2
|
+
|
3
|
+
services:
|
4
|
+
ruby-3.1:
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
args:
|
8
|
+
RUBY_VERSION: 3.1
|
9
|
+
ruby-3.0:
|
10
|
+
build:
|
11
|
+
context: .
|
12
|
+
args:
|
13
|
+
RUBY_VERSION: 3.0
|
14
|
+
ruby-2.7:
|
15
|
+
build:
|
16
|
+
context: .
|
17
|
+
args:
|
18
|
+
RUBY_VERSION: 2.7
|
19
|
+
ruby-2.6:
|
20
|
+
build:
|
21
|
+
context: .
|
22
|
+
args:
|
23
|
+
RUBY_VERSION: 2.6
|
@@ -13,6 +13,7 @@ module Net
|
|
13
13
|
module Authentication
|
14
14
|
# Class for representing agent-specific errors.
|
15
15
|
class AgentError < Net::SSH::Exception; end
|
16
|
+
|
16
17
|
# An exception for indicating that the SSH agent is not available.
|
17
18
|
class AgentNotAvailable < AgentError; end
|
18
19
|
|
@@ -39,6 +40,8 @@ module Net
|
|
39
40
|
SSH2_AGENT_ADD_IDENTITY = 17
|
40
41
|
SSH2_AGENT_REMOVE_IDENTITY = 18
|
41
42
|
SSH2_AGENT_REMOVE_ALL_IDENTITIES = 19
|
43
|
+
SSH2_AGENT_LOCK = 22
|
44
|
+
SSH2_AGENT_UNLOCK = 23
|
42
45
|
SSH2_AGENT_ADD_ID_CONSTRAINED = 25
|
43
46
|
SSH2_AGENT_FAILURE = 30
|
44
47
|
SSH2_AGENT_VERSION_RESPONSE = 103
|
@@ -62,7 +65,7 @@ module Net
|
|
62
65
|
|
63
66
|
# Instantiates a new agent object, connects to a running SSH agent,
|
64
67
|
# negotiates the agent protocol version, and returns the agent object.
|
65
|
-
def self.connect(logger=nil, agent_socket_factory = nil, identity_agent = nil)
|
68
|
+
def self.connect(logger = nil, agent_socket_factory = nil, identity_agent = nil)
|
66
69
|
agent = new(logger)
|
67
70
|
agent.connect!(agent_socket_factory, identity_agent)
|
68
71
|
agent.negotiate!
|
@@ -71,7 +74,7 @@ module Net
|
|
71
74
|
|
72
75
|
# Creates a new Agent object, using the optional logger instance to
|
73
76
|
# report status.
|
74
|
-
def initialize(logger=nil)
|
77
|
+
def initialize(logger = nil)
|
75
78
|
self.logger = logger
|
76
79
|
end
|
77
80
|
|
@@ -85,9 +88,9 @@ module Net
|
|
85
88
|
if agent_socket_factory
|
86
89
|
agent_socket_factory.call
|
87
90
|
elsif identity_agent
|
88
|
-
unix_socket_class.open(identity_agent)
|
91
|
+
unix_socket_class.open(File.expand_path(identity_agent))
|
89
92
|
elsif ENV['SSH_AUTH_SOCK'] && unix_socket_class
|
90
|
-
unix_socket_class.open(ENV['SSH_AUTH_SOCK'])
|
93
|
+
unix_socket_class.open(File.expand_path(ENV['SSH_AUTH_SOCK']))
|
91
94
|
elsif Gem.win_platform? && RUBY_ENGINE != "jruby"
|
92
95
|
Pageant::Socket.open
|
93
96
|
else
|
@@ -105,6 +108,7 @@ module Net
|
|
105
108
|
type, body = send_and_wait(SSH2_AGENT_REQUEST_VERSION, :string, Transport::ServerVersion::PROTO_VERSION)
|
106
109
|
|
107
110
|
raise AgentNotAvailable, "SSH2 agents are not yet supported" if type == SSH2_AGENT_VERSION_RESPONSE
|
111
|
+
|
108
112
|
if type == SSH2_AGENT_FAILURE
|
109
113
|
debug { "Unexpected response type==#{type}, this will be ignored" }
|
110
114
|
elsif type != SSH_AGENT_RSA_IDENTITIES_ANSWER1 && type != SSH_AGENT_RSA_IDENTITIES_ANSWER2
|
@@ -173,7 +177,7 @@ module Net
|
|
173
177
|
|
174
178
|
req_type = constraints.empty? ? SSH2_AGENT_ADD_IDENTITY : SSH2_AGENT_ADD_ID_CONSTRAINED
|
175
179
|
type, = send_and_wait(req_type, :string, priv_key.ssh_type, :raw, blob_for_add(priv_key),
|
176
|
-
|
180
|
+
:string, comment, :raw, constraints)
|
177
181
|
raise AgentError, "could not add identity to agent" if type != SSH_AGENT_SUCCESS
|
178
182
|
end
|
179
183
|
|
@@ -189,6 +193,18 @@ module Net
|
|
189
193
|
raise AgentError, "could not remove all identity from agent" if type != SSH_AGENT_SUCCESS
|
190
194
|
end
|
191
195
|
|
196
|
+
# lock the ssh agent with password
|
197
|
+
def lock(password)
|
198
|
+
type, = send_and_wait(SSH2_AGENT_LOCK, :string, password)
|
199
|
+
raise AgentError, "could not lock agent" if type != SSH_AGENT_SUCCESS
|
200
|
+
end
|
201
|
+
|
202
|
+
# unlock the ssh agent with password
|
203
|
+
def unlock(password)
|
204
|
+
type, = send_and_wait(SSH2_AGENT_UNLOCK, :string, password)
|
205
|
+
raise AgentError, "could not unlock agent" if type != SSH_AGENT_SUCCESS
|
206
|
+
end
|
207
|
+
|
192
208
|
private
|
193
209
|
|
194
210
|
def unix_socket_class
|
@@ -235,31 +251,31 @@ module Net
|
|
235
251
|
case priv_key.ssh_type
|
236
252
|
when /^ssh-dss$/
|
237
253
|
Net::SSH::Buffer.from(:bignum, priv_key.p, :bignum, priv_key.q, :bignum, priv_key.g,
|
238
|
-
|
254
|
+
:bignum, priv_key.pub_key, :bignum, priv_key.priv_key).to_s
|
239
255
|
when /^ssh-dss-cert-v01@openssh\.com$/
|
240
256
|
Net::SSH::Buffer.from(:string, priv_key.to_blob, :bignum, priv_key.key.priv_key).to_s
|
241
257
|
when /^ecdsa\-sha2\-(\w*)$/
|
242
258
|
curve_name = OpenSSL::PKey::EC::CurveNameAliasInv[priv_key.group.curve_name]
|
243
259
|
Net::SSH::Buffer.from(:string, curve_name, :mstring, priv_key.public_key.to_bn.to_s(2),
|
244
|
-
|
260
|
+
:bignum, priv_key.private_key).to_s
|
245
261
|
when /^ecdsa\-sha2\-(\w*)-cert-v01@openssh\.com$/
|
246
262
|
Net::SSH::Buffer.from(:string, priv_key.to_blob, :bignum, priv_key.key.private_key).to_s
|
247
263
|
when /^ssh-ed25519$/
|
248
264
|
Net::SSH::Buffer.from(:string, priv_key.public_key.verify_key.to_bytes,
|
249
|
-
|
265
|
+
:string, priv_key.sign_key.keypair).to_s
|
250
266
|
when /^ssh-ed25519-cert-v01@openssh\.com$/
|
251
267
|
# Unlike the other certificate types, the public key is included after the certifiate.
|
252
268
|
Net::SSH::Buffer.from(:string, priv_key.to_blob,
|
253
|
-
|
254
|
-
|
269
|
+
:string, priv_key.key.public_key.verify_key.to_bytes,
|
270
|
+
:string, priv_key.key.sign_key.keypair).to_s
|
255
271
|
when /^ssh-rsa$/
|
256
272
|
# `n` and `e` are reversed compared to the ordering in `OpenSSL::PKey::RSA#to_blob`.
|
257
273
|
Net::SSH::Buffer.from(:bignum, priv_key.n, :bignum, priv_key.e, :bignum, priv_key.d,
|
258
|
-
|
274
|
+
:bignum, priv_key.iqmp, :bignum, priv_key.p, :bignum, priv_key.q).to_s
|
259
275
|
when /^ssh-rsa-cert-v01@openssh\.com$/
|
260
276
|
Net::SSH::Buffer.from(:string, priv_key.to_blob, :bignum, priv_key.key.d,
|
261
|
-
|
262
|
-
|
277
|
+
:bignum, priv_key.key.iqmp, :bignum, priv_key.key.p,
|
278
|
+
:bignum, priv_key.key.q).to_s
|
263
279
|
end
|
264
280
|
end
|
265
281
|
end
|