abiquo-installer-tests 20120104 → 20121023.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +11 -7
- data/bin/abiquo-installer-tests +68 -43
- data/tests/1.8.5/abiquo_ciab.rb +21 -0
- data/tests/1.8.5/abiquo_kvm.rb +25 -0
- data/tests/1.8.5/abiquo_lvmiscsi.rb +17 -0
- data/tests/1.8.5/abiquo_monolithic.rb +12 -0
- data/tests/1.8.5/abiquo_nfs_repository.rb +23 -0
- data/tests/1.8.5/abiquo_platform.rb +39 -0
- data/tests/1.8.5/abiquo_remote_services.rb +115 -0
- data/tests/1.8.5/abiquo_server.rb +63 -0
- data/tests/1.8.5/abiquo_v2v.rb +37 -0
- data/tests/1.8.5/abiquo_vbox.rb +27 -0
- data/tests/1.8.5/abiquo_xen.rb +27 -0
- data/tests/2.0/abiquo_ciab.rb +9 -0
- data/tests/2.0/abiquo_community_hypervisor.rb +52 -0
- data/tests/2.0/abiquo_kvm.rb +5 -23
- data/tests/2.0/abiquo_monolithic.rb +12 -1
- data/tests/2.0/abiquo_platform.rb +2 -2
- data/tests/2.0/abiquo_remote_services.rb +15 -38
- data/tests/2.0/abiquo_server.rb +7 -1
- data/tests/2.0/abiquo_v2v.rb +42 -0
- data/tests/2.0/abiquo_vbox.rb +5 -25
- data/tests/2.0/abiquo_xen.rb +5 -25
- data/tests/2.2.0/abiquo_ciab.rb +30 -0
- data/tests/2.2.0/abiquo_community_hypervisor.rb +52 -0
- data/tests/2.2.0/abiquo_kvm.rb +7 -0
- data/tests/2.2.0/abiquo_lvmiscsi.rb +17 -0
- data/tests/2.2.0/abiquo_monolithic.rb +23 -0
- data/tests/2.2.0/abiquo_nfs_repository.rb +23 -0
- data/tests/2.2.0/abiquo_platform.rb +35 -0
- data/tests/2.2.0/abiquo_remote_services.rb +96 -0
- data/tests/2.2.0/abiquo_server.rb +95 -0
- data/tests/2.2.0/abiquo_v2v.rb +79 -0
- data/tests/2.2.0/abiquo_vbox.rb +7 -0
- data/tests/2.2.0/abiquo_xen.rb +7 -0
- data/tests/2.3.0/abiquo_ciab.rb +30 -0
- data/tests/2.3.0/abiquo_community_hypervisor.rb +52 -0
- data/tests/2.3.0/abiquo_kvm.rb +7 -0
- data/tests/2.3.0/abiquo_lvmiscsi.rb +17 -0
- data/tests/2.3.0/abiquo_monolithic.rb +23 -0
- data/tests/2.3.0/abiquo_nfs_repository.rb +23 -0
- data/tests/2.3.0/abiquo_platform.rb +35 -0
- data/tests/2.3.0/abiquo_remote_services.rb +96 -0
- data/tests/2.3.0/abiquo_server.rb +95 -0
- data/tests/2.3.0/abiquo_v2v.rb +79 -0
- data/tests/2.3.0/abiquo_vbox.rb +7 -0
- data/tests/2.3.0/abiquo_xen.rb +7 -0
- data/tests/abiquo_postinst_test.rb +12 -1
- data/vendor/net-scp-1.0.4/CHANGELOG.rdoc +29 -0
- data/vendor/net-scp-1.0.4/Manifest +17 -0
- data/vendor/net-scp-1.0.4/README.rdoc +98 -0
- data/vendor/net-scp-1.0.4/Rakefile +83 -0
- data/vendor/net-scp-1.0.4/lib/net/scp.rb +432 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/download.rb +150 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/errors.rb +5 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/upload.rb +142 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/version.rb +18 -0
- data/vendor/net-scp-1.0.4/lib/uri/open-scp.rb +18 -0
- data/vendor/net-scp-1.0.4/lib/uri/scp.rb +35 -0
- data/vendor/net-scp-1.0.4/net-scp.gemspec +34 -0
- data/vendor/net-scp-1.0.4/setup.rb +1331 -0
- data/vendor/net-scp-1.0.4/test/common.rb +153 -0
- data/vendor/net-scp-1.0.4/test/test_all.rb +3 -0
- data/vendor/net-scp-1.0.4/test/test_download.rb +170 -0
- data/vendor/net-scp-1.0.4/test/test_scp.rb +60 -0
- data/vendor/net-scp-1.0.4/test/test_upload.rb +269 -0
- data/vendor/net-sftp-2.0.5/CHANGELOG.rdoc +49 -0
- data/vendor/net-sftp-2.0.5/Manifest +55 -0
- data/vendor/net-sftp-2.0.5/README.rdoc +96 -0
- data/vendor/net-sftp-2.0.5/Rakefile +30 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp.rb +70 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/constants.rb +187 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/errors.rb +39 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/dir.rb +93 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/download.rb +364 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/file.rb +176 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/file_factory.rb +60 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb +387 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/packet.rb +21 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol.rb +32 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/attributes.rb +315 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/base.rb +268 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/name.rb +43 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/02/base.rb +31 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/03/base.rb +35 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/attributes.rb +152 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/base.rb +94 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/name.rb +67 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/05/base.rb +66 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/06/attributes.rb +107 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/06/base.rb +63 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/base.rb +50 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/request.rb +91 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/response.rb +76 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/session.rb +952 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/version.rb +18 -0
- data/vendor/net-sftp-2.0.5/net-sftp.gemspec +34 -0
- data/vendor/net-sftp-2.0.5/setup.rb +1331 -0
- data/vendor/net-sftp-2.0.5/test/common.rb +172 -0
- data/vendor/net-sftp-2.0.5/test/protocol/01/test_attributes.rb +97 -0
- data/vendor/net-sftp-2.0.5/test/protocol/01/test_base.rb +210 -0
- data/vendor/net-sftp-2.0.5/test/protocol/01/test_name.rb +27 -0
- data/vendor/net-sftp-2.0.5/test/protocol/02/test_base.rb +26 -0
- data/vendor/net-sftp-2.0.5/test/protocol/03/test_base.rb +27 -0
- data/vendor/net-sftp-2.0.5/test/protocol/04/test_attributes.rb +148 -0
- data/vendor/net-sftp-2.0.5/test/protocol/04/test_base.rb +74 -0
- data/vendor/net-sftp-2.0.5/test/protocol/04/test_name.rb +53 -0
- data/vendor/net-sftp-2.0.5/test/protocol/05/test_base.rb +62 -0
- data/vendor/net-sftp-2.0.5/test/protocol/06/test_attributes.rb +124 -0
- data/vendor/net-sftp-2.0.5/test/protocol/06/test_base.rb +51 -0
- data/vendor/net-sftp-2.0.5/test/protocol/test_base.rb +42 -0
- data/vendor/net-sftp-2.0.5/test/test_all.rb +7 -0
- data/vendor/net-sftp-2.0.5/test/test_dir.rb +47 -0
- data/vendor/net-sftp-2.0.5/test/test_download.rb +252 -0
- data/vendor/net-sftp-2.0.5/test/test_file.rb +159 -0
- data/vendor/net-sftp-2.0.5/test/test_file_factory.rb +48 -0
- data/vendor/net-sftp-2.0.5/test/test_packet.rb +9 -0
- data/vendor/net-sftp-2.0.5/test/test_protocol.rb +17 -0
- data/vendor/net-sftp-2.0.5/test/test_request.rb +71 -0
- data/vendor/net-sftp-2.0.5/test/test_response.rb +53 -0
- data/vendor/net-sftp-2.0.5/test/test_session.rb +741 -0
- data/vendor/net-sftp-2.0.5/test/test_upload.rb +219 -0
- data/vendor/net-ssh-2.5.2/CHANGELOG.rdoc +295 -0
- data/vendor/net-ssh-2.5.2/LICENSE.rdoc +19 -0
- data/vendor/net-ssh-2.5.2/Manifest +132 -0
- data/vendor/net-ssh-2.5.2/README.rdoc +184 -0
- data/vendor/net-ssh-2.5.2/Rakefile +88 -0
- data/vendor/net-ssh-2.5.2/Rudyfile +96 -0
- data/vendor/net-ssh-2.5.2/THANKS.rdoc +19 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh.rb +223 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent.rb +23 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent/java_pageant.rb +85 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent/socket.rb +170 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/constants.rb +18 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/key_manager.rb +253 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/abstract.rb +60 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/hostbased.rb +75 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/keyboard_interactive.rb +70 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/password.rb +43 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/publickey.rb +96 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/pageant.rb +264 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/session.rb +154 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/buffer.rb +350 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/buffered_io.rb +198 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/config.rb +207 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/channel.rb +630 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/constants.rb +33 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/session.rb +597 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/term.rb +178 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/errors.rb +88 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/key_factory.rb +107 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/known_hosts.rb +141 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/loggable.rb +61 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/packet.rb +102 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/prompt.rb +93 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/command.rb +75 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/errors.rb +14 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/http.rb +94 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/socks4.rb +70 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/socks5.rb +142 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/ruby_compat.rb +51 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/service/forward.rb +298 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test.rb +89 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/channel.rb +129 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/extensions.rb +152 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/kex.rb +44 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/local_packet.rb +51 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/packet.rb +81 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/remote_packet.rb +38 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/script.rb +157 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/socket.rb +64 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/algorithms.rb +407 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/cipher_factory.rb +106 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/constants.rb +32 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/ctr.rb +95 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac.rb +45 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/abstract.rb +79 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/md5.rb +12 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/none.rb +15 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/ripemd160.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha1.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_256.rb +15 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_256_96.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_512.rb +14 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_512_96.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/identity_cipher.rb +55 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex.rb +28 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +44 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +216 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +80 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +15 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +93 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/key_expander.rb +26 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/openssl.rb +237 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/packet_stream.rb +235 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/server_version.rb +71 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/session.rb +278 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/state.rb +206 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/lenient.rb +30 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/null.rb +12 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/strict.rb +53 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/version.rb +62 -0
- data/vendor/net-ssh-2.5.2/net-ssh.gemspec +172 -0
- data/vendor/net-ssh-2.5.2/setup.rb +1585 -0
- data/vendor/net-ssh-2.5.2/support/arcfour_check.rb +20 -0
- data/vendor/net-ssh-2.5.2/support/ssh_tunnel_bug.rb +65 -0
- data/vendor/net-ssh-2.5.2/test/README.txt +43 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/common.rb +28 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_abstract.rb +51 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_hostbased.rb +114 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_keyboard_interactive.rb +100 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_password.rb +52 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_publickey.rb +148 -0
- data/vendor/net-ssh-2.5.2/test/authentication/test_agent.rb +205 -0
- data/vendor/net-ssh-2.5.2/test/authentication/test_key_manager.rb +218 -0
- data/vendor/net-ssh-2.5.2/test/authentication/test_session.rb +106 -0
- data/vendor/net-ssh-2.5.2/test/common.rb +107 -0
- data/vendor/net-ssh-2.5.2/test/configs/eqsign +3 -0
- data/vendor/net-ssh-2.5.2/test/configs/exact_match +8 -0
- data/vendor/net-ssh-2.5.2/test/configs/host_plus +10 -0
- data/vendor/net-ssh-2.5.2/test/configs/multihost +4 -0
- data/vendor/net-ssh-2.5.2/test/configs/nohost +19 -0
- data/vendor/net-ssh-2.5.2/test/configs/numeric_host +4 -0
- data/vendor/net-ssh-2.5.2/test/configs/wild_cards +14 -0
- data/vendor/net-ssh-2.5.2/test/connection/test_channel.rb +467 -0
- data/vendor/net-ssh-2.5.2/test/connection/test_session.rb +488 -0
- data/vendor/net-ssh-2.5.2/test/known_hosts/github +1 -0
- data/vendor/net-ssh-2.5.2/test/manual/test_forward.rb +223 -0
- data/vendor/net-ssh-2.5.2/test/start/test_transport.rb +28 -0
- data/vendor/net-ssh-2.5.2/test/test_all.rb +9 -0
- data/vendor/net-ssh-2.5.2/test/test_buffer.rb +426 -0
- data/vendor/net-ssh-2.5.2/test/test_buffered_io.rb +63 -0
- data/vendor/net-ssh-2.5.2/test/test_config.rb +120 -0
- data/vendor/net-ssh-2.5.2/test/test_key_factory.rb +121 -0
- data/vendor/net-ssh-2.5.2/test/test_known_hosts.rb +13 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_md5.rb +39 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_md5_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_none.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_ripemd160.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha1.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha1_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_256.rb +35 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_256_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_512.rb +35 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_512_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group14_sha1.rb +13 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +33 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp256.rb +161 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp384.rb +37 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp521.rb +37 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_algorithms.rb +330 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_cipher_factory.rb +441 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_hmac.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_identity_cipher.rb +40 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_packet_stream.rb +1745 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_server_version.rb +78 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_session.rb +315 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_state.rb +179 -0
- metadata +325 -78
@@ -0,0 +1,19 @@
|
|
1
|
+
Net::SSH was originally written by Jamis Buck <jamis@37signals.com>. In
|
2
|
+
addition, the following individuals are gratefully acknowledged for their
|
3
|
+
contributions:
|
4
|
+
|
5
|
+
GOTOU Yuuzou <gotoyuzo@notwork.org>
|
6
|
+
* help and code related to OpenSSL
|
7
|
+
|
8
|
+
Guillaume Marçais <guillaume.marcais@free.fr>
|
9
|
+
* support for communicating with the the PuTTY "pageant" process
|
10
|
+
|
11
|
+
Daniel Berger <djberg96@yahoo.com>
|
12
|
+
* help getting unit tests in earlier Net::SSH versions to pass in Windows
|
13
|
+
* initial version of Net::SSH::Config provided inspiration and encouragement
|
14
|
+
|
15
|
+
Chris Andrews <chris@nodnol.org> and Lee Jensen <lee@outerim.com>
|
16
|
+
* support for ssh agent forwarding
|
17
|
+
|
18
|
+
Hiroshi Nakamura
|
19
|
+
* fixed errors with JRuby tests
|
@@ -0,0 +1,223 @@
|
|
1
|
+
# Make sure HOME is set, regardless of OS, so that File.expand_path works
|
2
|
+
# as expected with tilde characters.
|
3
|
+
ENV['HOME'] ||= ENV['HOMEPATH'] ? "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" : "."
|
4
|
+
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
require 'net/ssh/config'
|
8
|
+
require 'net/ssh/errors'
|
9
|
+
require 'net/ssh/loggable'
|
10
|
+
require 'net/ssh/transport/session'
|
11
|
+
require 'net/ssh/authentication/session'
|
12
|
+
require 'net/ssh/connection/session'
|
13
|
+
|
14
|
+
module Net
|
15
|
+
|
16
|
+
# Net::SSH is a library for interacting, programmatically, with remote
|
17
|
+
# processes via the SSH2 protocol. Sessions are always initiated via
|
18
|
+
# Net::SSH.start. From there, a program interacts with the new SSH session
|
19
|
+
# via the convenience methods on Net::SSH::Connection::Session, by opening
|
20
|
+
# and interacting with new channels (Net::SSH::Connection:Session#open_channel
|
21
|
+
# and Net::SSH::Connection::Channel), or by forwarding local and/or
|
22
|
+
# remote ports through the connection (Net::SSH::Service::Forward).
|
23
|
+
#
|
24
|
+
# The SSH protocol is very event-oriented. Requests are sent from the client
|
25
|
+
# to the server, and are answered asynchronously. This gives great flexibility
|
26
|
+
# (since clients can have multiple requests pending at a time), but it also
|
27
|
+
# adds complexity. Net::SSH tries to manage this complexity by providing
|
28
|
+
# some simpler methods of synchronous communication (see Net::SSH::Connection::Session#exec!).
|
29
|
+
#
|
30
|
+
# In general, though, and if you want to do anything more complicated than
|
31
|
+
# simply executing commands and capturing their output, you'll need to use
|
32
|
+
# channels (Net::SSH::Connection::Channel) to build state machines that are
|
33
|
+
# executed while the event loop runs (Net::SSH::Connection::Session#loop).
|
34
|
+
#
|
35
|
+
# Net::SSH::Connection::Session and Net::SSH::Connection::Channel have more
|
36
|
+
# information about this technique.
|
37
|
+
#
|
38
|
+
# = "Um, all I want to do is X, just show me how!"
|
39
|
+
#
|
40
|
+
# == X == "execute a command and capture the output"
|
41
|
+
#
|
42
|
+
# Net::SSH.start("host", "user", :password => "password") do |ssh|
|
43
|
+
# result = ssh.exec!("ls -l")
|
44
|
+
# puts result
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# == X == "forward connections on a local port to a remote host"
|
48
|
+
#
|
49
|
+
# Net::SSH.start("host", "user", :password => "password") do |ssh|
|
50
|
+
# ssh.forward.local(1234, "www.google.com", 80)
|
51
|
+
# ssh.loop { true }
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# == X == "forward connections on a remote port to the local host"
|
55
|
+
#
|
56
|
+
# Net::SSH.start("host", "user", :password => "password") do |ssh|
|
57
|
+
# ssh.forward.remote(80, "www.google.com", 1234)
|
58
|
+
# ssh.loop { true }
|
59
|
+
# end
|
60
|
+
module SSH
|
61
|
+
# This is the set of options that Net::SSH.start recognizes. See
|
62
|
+
# Net::SSH.start for a description of each option.
|
63
|
+
VALID_OPTIONS = [
|
64
|
+
:auth_methods, :bind_address, :compression, :compression_level, :config,
|
65
|
+
:encryption, :forward_agent, :hmac, :host_key, :kex, :keys, :key_data,
|
66
|
+
:languages, :logger, :paranoid, :password, :port, :proxy,
|
67
|
+
:rekey_blocks_limit,:rekey_limit, :rekey_packet_limit, :timeout, :verbose,
|
68
|
+
:global_known_hosts_file, :user_known_hosts_file, :host_key_alias,
|
69
|
+
:host_name, :user, :properties, :passphrase, :keys_only
|
70
|
+
]
|
71
|
+
|
72
|
+
# The standard means of starting a new SSH connection. When used with a
|
73
|
+
# block, the connection will be closed when the block terminates, otherwise
|
74
|
+
# the connection will just be returned. The yielded (or returned) value
|
75
|
+
# will be an instance of Net::SSH::Connection::Session (q.v.). (See also
|
76
|
+
# Net::SSH::Connection::Channel and Net::SSH::Service::Forward.)
|
77
|
+
#
|
78
|
+
# Net::SSH.start("host", "user") do |ssh|
|
79
|
+
# ssh.exec! "cp /some/file /another/location"
|
80
|
+
# hostname = ssh.exec!("hostname")
|
81
|
+
#
|
82
|
+
# ssh.open_channel do |ch|
|
83
|
+
# ch.exec "sudo -p 'sudo password: ' ls" do |ch, success|
|
84
|
+
# abort "could not execute sudo ls" unless success
|
85
|
+
#
|
86
|
+
# ch.on_data do |ch, data|
|
87
|
+
# print data
|
88
|
+
# if data =~ /sudo password: /
|
89
|
+
# ch.send_data("password\n")
|
90
|
+
# end
|
91
|
+
# end
|
92
|
+
# end
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# ssh.loop
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# This method accepts the following options (all are optional):
|
99
|
+
#
|
100
|
+
# * :auth_methods => an array of authentication methods to try
|
101
|
+
# * :bind_address => the IP address on the connecting machine to use in
|
102
|
+
# establishing connection. (:bind_address is discarded if :proxy
|
103
|
+
# is set.)
|
104
|
+
# * :compression => the compression algorithm to use, or +true+ to use
|
105
|
+
# whatever is supported.
|
106
|
+
# * :compression_level => the compression level to use when sending data
|
107
|
+
# * :config => set to +true+ to load the default OpenSSH config files
|
108
|
+
# (~/.ssh/config, /etc/ssh_config), or to +false+ to not load them, or to
|
109
|
+
# a file-name (or array of file-names) to load those specific configuration
|
110
|
+
# files. Defaults to +true+.
|
111
|
+
# * :encryption => the encryption cipher (or ciphers) to use
|
112
|
+
# * :forward_agent => set to true if you want the SSH agent connection to
|
113
|
+
# be forwarded
|
114
|
+
# * :global_known_hosts_file => the location of the global known hosts
|
115
|
+
# file. Set to an array if you want to specify multiple global known
|
116
|
+
# hosts files. Defaults to %w(/etc/ssh/known_hosts /etc/ssh/known_hosts2).
|
117
|
+
# * :hmac => the hmac algorithm (or algorithms) to use
|
118
|
+
# * :host_key => the host key algorithm (or algorithms) to use
|
119
|
+
# * :host_key_alias => the host name to use when looking up or adding a
|
120
|
+
# host to a known_hosts dictionary file
|
121
|
+
# * :host_name => the real host name or IP to log into. This is used
|
122
|
+
# instead of the +host+ parameter, and is primarily only useful when
|
123
|
+
# specified in an SSH configuration file. It lets you specify an
|
124
|
+
# "alias", similarly to adding an entry in /etc/hosts but without needing
|
125
|
+
# to modify /etc/hosts.
|
126
|
+
# * :kex => the key exchange algorithm (or algorithms) to use
|
127
|
+
# * :keys => an array of file names of private keys to use for publickey
|
128
|
+
# and hostbased authentication
|
129
|
+
# * :key_data => an array of strings, with each element of the array being
|
130
|
+
# a raw private key in PEM format.
|
131
|
+
# * :keys_only => set to +true+ to use only private keys from +keys+ and
|
132
|
+
# +key_data+ parameters, even if ssh-agent offers more identities. This
|
133
|
+
# option is intended for situations where ssh-agent offers many different
|
134
|
+
# identites.
|
135
|
+
# * :logger => the logger instance to use when logging
|
136
|
+
# * :paranoid => either true, false, or :very, specifying how strict
|
137
|
+
# host-key verification should be
|
138
|
+
# * :passphrase => the passphrase to use when loading a private key (default
|
139
|
+
# is +nil+, for no passphrase)
|
140
|
+
# * :password => the password to use to login
|
141
|
+
# * :port => the port to use when connecting to the remote host
|
142
|
+
# * :properties => a hash of key/value pairs to add to the new connection's
|
143
|
+
# properties (see Net::SSH::Connection::Session#properties)
|
144
|
+
# * :proxy => a proxy instance (see Proxy) to use when connecting
|
145
|
+
# * :rekey_blocks_limit => the max number of blocks to process before rekeying
|
146
|
+
# * :rekey_limit => the max number of bytes to process before rekeying
|
147
|
+
# * :rekey_packet_limit => the max number of packets to process before rekeying
|
148
|
+
# * :timeout => how long to wait for the initial connection to be made
|
149
|
+
# * :user => the user name to log in as; this overrides the +user+
|
150
|
+
# parameter, and is primarily only useful when provided via an SSH
|
151
|
+
# configuration file.
|
152
|
+
# * :user_known_hosts_file => the location of the user known hosts file.
|
153
|
+
# Set to an array to specify multiple user known hosts files.
|
154
|
+
# Defaults to %w(~/.ssh/known_hosts ~/.ssh/known_hosts2).
|
155
|
+
# * :verbose => how verbose to be (Logger verbosity constants, Logger::DEBUG
|
156
|
+
# is very verbose, Logger::FATAL is all but silent). Logger::FATAL is the
|
157
|
+
# default. The symbols :debug, :info, :warn, :error, and :fatal are also
|
158
|
+
# supported and are translated to the corresponding Logger constant.
|
159
|
+
def self.start(host, user, options={}, &block)
|
160
|
+
invalid_options = options.keys - VALID_OPTIONS
|
161
|
+
if invalid_options.any?
|
162
|
+
raise ArgumentError, "invalid option(s): #{invalid_options.join(', ')}"
|
163
|
+
end
|
164
|
+
|
165
|
+
options[:user] = user if user
|
166
|
+
options = configuration_for(host, options.fetch(:config, true)).merge(options)
|
167
|
+
host = options.fetch(:host_name, host)
|
168
|
+
|
169
|
+
if !options.key?(:logger)
|
170
|
+
options[:logger] = Logger.new(STDERR)
|
171
|
+
options[:logger].level = Logger::FATAL
|
172
|
+
end
|
173
|
+
|
174
|
+
if options[:verbose]
|
175
|
+
options[:logger].level = case options[:verbose]
|
176
|
+
when Fixnum then options[:verbose]
|
177
|
+
when :debug then Logger::DEBUG
|
178
|
+
when :info then Logger::INFO
|
179
|
+
when :warn then Logger::WARN
|
180
|
+
when :error then Logger::ERROR
|
181
|
+
when :fatal then Logger::FATAL
|
182
|
+
else raise ArgumentError, "can't convert #{options[:verbose].inspect} to any of the Logger level constants"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
transport = Transport::Session.new(host, options)
|
187
|
+
auth = Authentication::Session.new(transport, options)
|
188
|
+
|
189
|
+
user = options.fetch(:user, user)
|
190
|
+
if auth.authenticate("ssh-connection", user, options[:password])
|
191
|
+
connection = Connection::Session.new(transport, options)
|
192
|
+
if block_given?
|
193
|
+
yield connection
|
194
|
+
connection.close
|
195
|
+
else
|
196
|
+
return connection
|
197
|
+
end
|
198
|
+
else
|
199
|
+
transport.close
|
200
|
+
raise AuthenticationFailed, user
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns a hash of the configuration options for the given host, as read
|
205
|
+
# from the SSH configuration file(s). If +use_ssh_config+ is true (the
|
206
|
+
# default), this will load configuration from both ~/.ssh/config and
|
207
|
+
# /etc/ssh_config. If +use_ssh_config+ is nil or false, nothing will be
|
208
|
+
# loaded (and an empty hash returned). Otherwise, +use_ssh_config+ may
|
209
|
+
# be a file name (or array of file names) of SSH configuration file(s)
|
210
|
+
# to read.
|
211
|
+
#
|
212
|
+
# See Net::SSH::Config for the full description of all supported options.
|
213
|
+
def self.configuration_for(host, use_ssh_config=true)
|
214
|
+
files = case use_ssh_config
|
215
|
+
when true then Net::SSH::Config.default_files
|
216
|
+
when false, nil then return {}
|
217
|
+
else Array(use_ssh_config)
|
218
|
+
end
|
219
|
+
|
220
|
+
Net::SSH::Config.for(host, files)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'net/ssh/buffer'
|
2
|
+
require 'net/ssh/errors'
|
3
|
+
require 'net/ssh/loggable'
|
4
|
+
|
5
|
+
module Net; module SSH; module Authentication
|
6
|
+
PLATFORM = File::ALT_SEPARATOR \
|
7
|
+
? RUBY_PLATFORM =~ /java/ ? :java_win32 : :win32 \
|
8
|
+
: RUBY_PLATFORM =~ /java/ ? :java : :unix
|
9
|
+
|
10
|
+
# A trivial exception class for representing agent-specific errors.
|
11
|
+
class AgentError < Net::SSH::Exception; end
|
12
|
+
|
13
|
+
# An exception for indicating that the SSH agent is not available.
|
14
|
+
class AgentNotAvailable < AgentError; end
|
15
|
+
end; end; end
|
16
|
+
|
17
|
+
case Net::SSH::Authentication::PLATFORM
|
18
|
+
when :java_win32
|
19
|
+
# Java pageant requires whole different agent.
|
20
|
+
require 'net/ssh/authentication/agent/java_pageant'
|
21
|
+
else
|
22
|
+
require 'net/ssh/authentication/agent/socket'
|
23
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'jruby_pageant'
|
2
|
+
|
3
|
+
module Net; module SSH; module Authentication
|
4
|
+
|
5
|
+
# This class implements an agent for JRuby + Pageant.
|
6
|
+
#
|
7
|
+
# Written by Artūras Šlajus <arturas.slajus@gmail.com>
|
8
|
+
class Agent
|
9
|
+
include Loggable
|
10
|
+
include JRubyPageant
|
11
|
+
|
12
|
+
# A simple module for extending keys, to allow blobs and comments to be
|
13
|
+
# specified for them.
|
14
|
+
module Key
|
15
|
+
# :blob is used by OpenSSL::PKey::RSA#to_blob
|
16
|
+
attr_accessor :java_blob
|
17
|
+
attr_accessor :comment
|
18
|
+
end
|
19
|
+
|
20
|
+
# Instantiates a new agent object, connects to a running SSH agent,
|
21
|
+
# negotiates the agent protocol version, and returns the agent object.
|
22
|
+
def self.connect(logger=nil)
|
23
|
+
agent = new(logger)
|
24
|
+
agent.connect!
|
25
|
+
agent
|
26
|
+
end
|
27
|
+
|
28
|
+
# Creates a new Agent object, using the optional logger instance to
|
29
|
+
# report status.
|
30
|
+
def initialize(logger=nil)
|
31
|
+
self.logger = logger
|
32
|
+
end
|
33
|
+
|
34
|
+
# Connect to the agent process using the socket factory and socket name
|
35
|
+
# given by the attribute writers. If the agent on the other end of the
|
36
|
+
# socket reports that it is an SSH2-compatible agent, this will fail
|
37
|
+
# (it only supports the ssh-agent distributed by OpenSSH).
|
38
|
+
def connect!
|
39
|
+
debug { "connecting to Pageant ssh-agent (via java connector)" }
|
40
|
+
@agent_proxy = JRubyPageant.create
|
41
|
+
unless @agent_proxy.is_running
|
42
|
+
raise AgentNotAvailable, "Pageant is not running!"
|
43
|
+
end
|
44
|
+
debug { "connection to Pageant ssh-agent (via java connector) succeeded" }
|
45
|
+
rescue AgentProxyException => e
|
46
|
+
error { "could not connect to Pageant ssh-agent (via java connector)" }
|
47
|
+
raise AgentNotAvailable, e.message, e.backtrace
|
48
|
+
end
|
49
|
+
|
50
|
+
# Return an array of all identities (public keys) known to the agent.
|
51
|
+
# Each key returned is augmented with a +comment+ property which is set
|
52
|
+
# to the comment returned by the agent for that key.
|
53
|
+
def identities
|
54
|
+
debug { "getting identities from Pageant" }
|
55
|
+
@agent_proxy.get_identities.map do |identity|
|
56
|
+
blob = identity.get_blob
|
57
|
+
key = Buffer.new(String.from_java_bytes(blob)).read_key
|
58
|
+
key.extend(Key)
|
59
|
+
key.java_blob = blob
|
60
|
+
key.comment = String.from_java_bytes(identity.get_comment)
|
61
|
+
key
|
62
|
+
end
|
63
|
+
rescue AgentProxyException => e
|
64
|
+
raise AgentError, "Cannot get identities: #{e.message}", e.backtrace
|
65
|
+
end
|
66
|
+
|
67
|
+
# Simulate agent close. This agent reference is no longer able to
|
68
|
+
# query the agent.
|
69
|
+
def close
|
70
|
+
@agent_proxy = nil
|
71
|
+
end
|
72
|
+
|
73
|
+
# Using the agent and the given public key, sign the given data. The
|
74
|
+
# signature is returned in SSH2 format.
|
75
|
+
def sign(key, data)
|
76
|
+
signed = @agent_proxy.sign(key.java_blob, data.to_java_bytes)
|
77
|
+
String.from_java_bytes(signed)
|
78
|
+
rescue AgentProxyException => e
|
79
|
+
raise AgentError,
|
80
|
+
"agent could not sign data with requested identity: #{e.message}",
|
81
|
+
e.backtrace
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end; end; end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'net/ssh/transport/server_version'
|
2
|
+
|
3
|
+
# Only load pageant on Windows
|
4
|
+
if Net::SSH::Authentication::PLATFORM == :win32
|
5
|
+
require 'net/ssh/authentication/pageant'
|
6
|
+
end
|
7
|
+
|
8
|
+
module Net; module SSH; module Authentication
|
9
|
+
|
10
|
+
# This class implements a simple client for the ssh-agent protocol. It
|
11
|
+
# does not implement any specific protocol, but instead copies the
|
12
|
+
# behavior of the ssh-agent functions in the OpenSSH library (3.8).
|
13
|
+
#
|
14
|
+
# This means that although it behaves like a SSH1 client, it also has
|
15
|
+
# some SSH2 functionality (like signing data).
|
16
|
+
class Agent
|
17
|
+
include Loggable
|
18
|
+
|
19
|
+
# A simple module for extending keys, to allow comments to be specified
|
20
|
+
# for them.
|
21
|
+
module Comment
|
22
|
+
attr_accessor :comment
|
23
|
+
end
|
24
|
+
|
25
|
+
SSH2_AGENT_REQUEST_VERSION = 1
|
26
|
+
SSH2_AGENT_REQUEST_IDENTITIES = 11
|
27
|
+
SSH2_AGENT_IDENTITIES_ANSWER = 12
|
28
|
+
SSH2_AGENT_SIGN_REQUEST = 13
|
29
|
+
SSH2_AGENT_SIGN_RESPONSE = 14
|
30
|
+
SSH2_AGENT_FAILURE = 30
|
31
|
+
SSH2_AGENT_VERSION_RESPONSE = 103
|
32
|
+
|
33
|
+
SSH_COM_AGENT2_FAILURE = 102
|
34
|
+
|
35
|
+
SSH_AGENT_REQUEST_RSA_IDENTITIES = 1
|
36
|
+
SSH_AGENT_RSA_IDENTITIES_ANSWER1 = 2
|
37
|
+
SSH_AGENT_RSA_IDENTITIES_ANSWER2 = 5
|
38
|
+
SSH_AGENT_FAILURE = 5
|
39
|
+
|
40
|
+
# The underlying socket being used to communicate with the SSH agent.
|
41
|
+
attr_reader :socket
|
42
|
+
|
43
|
+
# Instantiates a new agent object, connects to a running SSH agent,
|
44
|
+
# negotiates the agent protocol version, and returns the agent object.
|
45
|
+
def self.connect(logger=nil)
|
46
|
+
agent = new(logger)
|
47
|
+
agent.connect!
|
48
|
+
agent.negotiate!
|
49
|
+
agent
|
50
|
+
end
|
51
|
+
|
52
|
+
# Creates a new Agent object, using the optional logger instance to
|
53
|
+
# report status.
|
54
|
+
def initialize(logger=nil)
|
55
|
+
self.logger = logger
|
56
|
+
end
|
57
|
+
|
58
|
+
# Connect to the agent process using the socket factory and socket name
|
59
|
+
# given by the attribute writers. If the agent on the other end of the
|
60
|
+
# socket reports that it is an SSH2-compatible agent, this will fail
|
61
|
+
# (it only supports the ssh-agent distributed by OpenSSH).
|
62
|
+
def connect!
|
63
|
+
begin
|
64
|
+
debug { "connecting to ssh-agent" }
|
65
|
+
@socket = agent_socket_factory.open(ENV['SSH_AUTH_SOCK'])
|
66
|
+
rescue
|
67
|
+
error { "could not connect to ssh-agent" }
|
68
|
+
raise AgentNotAvailable, $!.message
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Attempts to negotiate the SSH agent protocol version. Raises an error
|
73
|
+
# if the version could not be negotiated successfully.
|
74
|
+
def negotiate!
|
75
|
+
# determine what type of agent we're communicating with
|
76
|
+
type, body = send_and_wait(SSH2_AGENT_REQUEST_VERSION, :string, Transport::ServerVersion::PROTO_VERSION)
|
77
|
+
|
78
|
+
if type == SSH2_AGENT_VERSION_RESPONSE
|
79
|
+
raise NotImplementedError, "SSH2 agents are not yet supported"
|
80
|
+
elsif type != SSH_AGENT_RSA_IDENTITIES_ANSWER1 && type != SSH_AGENT_RSA_IDENTITIES_ANSWER2
|
81
|
+
raise AgentError, "unknown response from agent: #{type}, #{body.to_s.inspect}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Return an array of all identities (public keys) known to the agent.
|
86
|
+
# Each key returned is augmented with a +comment+ property which is set
|
87
|
+
# to the comment returned by the agent for that key.
|
88
|
+
def identities
|
89
|
+
type, body = send_and_wait(SSH2_AGENT_REQUEST_IDENTITIES)
|
90
|
+
raise AgentError, "could not get identity count" if agent_failed(type)
|
91
|
+
raise AgentError, "bad authentication reply: #{type}" if type != SSH2_AGENT_IDENTITIES_ANSWER
|
92
|
+
|
93
|
+
identities = []
|
94
|
+
body.read_long.times do
|
95
|
+
key = Buffer.new(body.read_string).read_key
|
96
|
+
key.extend(Comment)
|
97
|
+
key.comment = body.read_string
|
98
|
+
identities.push key
|
99
|
+
end
|
100
|
+
|
101
|
+
return identities
|
102
|
+
end
|
103
|
+
|
104
|
+
# Closes this socket. This agent reference is no longer able to
|
105
|
+
# query the agent.
|
106
|
+
def close
|
107
|
+
@socket.close
|
108
|
+
end
|
109
|
+
|
110
|
+
# Using the agent and the given public key, sign the given data. The
|
111
|
+
# signature is returned in SSH2 format.
|
112
|
+
def sign(key, data)
|
113
|
+
type, reply = send_and_wait(SSH2_AGENT_SIGN_REQUEST, :string, Buffer.from(:key, key), :string, data, :long, 0)
|
114
|
+
|
115
|
+
if agent_failed(type)
|
116
|
+
raise AgentError, "agent could not sign data with requested identity"
|
117
|
+
elsif type != SSH2_AGENT_SIGN_RESPONSE
|
118
|
+
raise AgentError, "bad authentication response #{type}"
|
119
|
+
end
|
120
|
+
|
121
|
+
return reply.read_string
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
# Returns the agent socket factory to use.
|
127
|
+
def agent_socket_factory
|
128
|
+
if Net::SSH::Authentication::PLATFORM == :win32
|
129
|
+
Pageant::socket_factory
|
130
|
+
else
|
131
|
+
UNIXSocket
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Send a new packet of the given type, with the associated data.
|
136
|
+
def send_packet(type, *args)
|
137
|
+
buffer = Buffer.from(*args)
|
138
|
+
data = [buffer.length + 1, type.to_i, buffer.to_s].pack("NCA*")
|
139
|
+
debug { "sending agent request #{type} len #{buffer.length}" }
|
140
|
+
@socket.send data, 0
|
141
|
+
end
|
142
|
+
|
143
|
+
# Read the next packet from the agent. This will return a two-part
|
144
|
+
# tuple consisting of the packet type, and the packet's body (which
|
145
|
+
# is returned as a Net::SSH::Buffer).
|
146
|
+
def read_packet
|
147
|
+
buffer = Net::SSH::Buffer.new(@socket.read(4))
|
148
|
+
buffer.append(@socket.read(buffer.read_long))
|
149
|
+
type = buffer.read_byte
|
150
|
+
debug { "received agent packet #{type} len #{buffer.length-4}" }
|
151
|
+
return type, buffer
|
152
|
+
end
|
153
|
+
|
154
|
+
# Send the given packet and return the subsequent reply from the agent.
|
155
|
+
# (See #send_packet and #read_packet).
|
156
|
+
def send_and_wait(type, *args)
|
157
|
+
send_packet(type, *args)
|
158
|
+
read_packet
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns +true+ if the parameter indicates a "failure" response from
|
162
|
+
# the agent, and +false+ otherwise.
|
163
|
+
def agent_failed(type)
|
164
|
+
type == SSH_AGENT_FAILURE ||
|
165
|
+
type == SSH2_AGENT_FAILURE ||
|
166
|
+
type == SSH_COM_AGENT2_FAILURE
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end; end; end
|