net-ssh-krb-0.5.1/0000755000004100000410000000000013641340536013707 5ustar www-datawww-datanet-ssh-krb-0.5.1/README.md0000644000004100000410000000310713641340536015167 0ustar www-datawww-data# net-ssh-kerberos Add Kerberos (password-less) authentication capabilities to Net::SSH, without the need for modifying Net::SSH source code. This is a great way to help get Capistrano to be accepted in mid-to-large size enterprises with strict security rules. No more getting locked out of the network because you mis-typed your password - even if your company prohibits public key or host-based authentication. If your organization uses Kerberos (many mid-to-large size corporations do), you can use this package to get password-less authentication without breaking your company's security guidelines. ## How to use with Capistrano Add the following lines to the top of your Capfile (the relevant :auth_method is "gssapi-with-mic") ``` require 'net/ssh/kerberos' set :ssh_options, { :auth_methods => %w(gssapi-with-mic publickey hostbased password keyboard-interactive) } ``` ## How to use with 'net/ssh' With bundler, add the following lines to Gemfile. ``` gem 'net-ssh', :require => 'net/ssh' gem 'net-ssh-krb' ``` Set :auth_methods in Net::SSH options. ``` #!/usr/bin/env ruby require 'rubygems' require 'bundler' Bundler.require Net::SSH.start('10.3.18.198', 'root', {:auth_methods => ["gssapi-with-mic"]}) do |ssh| puts ssh.exec!('hostname') end ``` ## Contributors - Joe Khoobyar http://github.com/joekhoobyar - Joshua Ballanco http://github.com/jballanc - Liu Lantao http://github.com/Lax - Chris Beer http://github.com/cbeer - Linda Julien http://github.com/ljulien ## Copyright Copyright (c) 2009-2011 Joe Khoobyar. See LICENSE for details. net-ssh-krb-0.5.1/spec/0000755000004100000410000000000013641340536014641 5ustar www-datawww-datanet-ssh-krb-0.5.1/spec/integration_spec.rb0000644000004100000410000000055213641340536020525 0ustar www-datawww-datarequire 'spec_helper' require 'net/ssh' describe "run commands on a kerberized server" do let :conn do Net::SSH.start(ENV['KERBEROS_TEST_HOST'], ENV['USER'], :auth_methods => ["gssapi-with-mic", "publickey"]) end it "it should work" do remote_user_name = conn.exec!("whoami") expect(remote_user_name.strip).to eq ENV['USER'] end end net-ssh-krb-0.5.1/spec/spec_helper.rb0000644000004100000410000000060513641340536017460 0ustar www-datawww-data$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'bundler/setup' require 'rspec' ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/ and ruby_engine != "jruby" require 'simplecov' SimpleCov.start end require 'net/ssh/kerberos' RSpec.configure do |config| end net-ssh-krb-0.5.1/.gitignore0000644000004100000410000000011713641340536015676 0ustar www-datawww-data*.sw? .buildpath .project .DS_Store coverage doc rdoc pkg Capfile Gemfile.lock net-ssh-krb-0.5.1/net-ssh-kerberos.gemspec0000644000004100000410000000147313641340536020454 0ustar www-datawww-data# -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{net-ssh-krb} s.version = "0.5.1" s.authors = ["Joe Khoobyar", "Chris Beer"] s.description = %q{Extends Net::SSH by adding Kerberos authentication capability for password-less logins on multiple platforms. } s.email = %q{joe@ankhcraft.com cabeer@stanford.edu} s.extra_rdoc_files = [ "LICENSE", "README.md" ] s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.homepage = %q{http://github.com/cbeer/net-ssh-kerberos} s.summary = %q{Add Kerberos support to Net::SSH} s.add_dependency 'net-ssh', '>= 2.0' s.add_dependency 'gssapi', '~> 1.3.0' s.add_development_dependency 'rake' s.add_development_dependency 'rspec', "~> 3.0" end net-ssh-krb-0.5.1/LICENSE0000644000004100000410000002613513641340536014723 0ustar www-datawww-data Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. net-ssh-krb-0.5.1/Rakefile0000644000004100000410000000021213641340536015347 0ustar www-datawww-datarequire 'rubygems' require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec net-ssh-krb-0.5.1/lib/0000755000004100000410000000000013641340536014455 5ustar www-datawww-datanet-ssh-krb-0.5.1/lib/net/0000755000004100000410000000000013641340536015243 5ustar www-datawww-datanet-ssh-krb-0.5.1/lib/net/ssh/0000755000004100000410000000000013641340536016040 5ustar www-datawww-datanet-ssh-krb-0.5.1/lib/net/ssh/krb.rb0000644000004100000410000000003213641340536017136 0ustar www-datawww-datarequire 'net/ssh/kerberos'net-ssh-krb-0.5.1/lib/net/ssh/authentication/0000755000004100000410000000000013641340536021057 5ustar www-datawww-datanet-ssh-krb-0.5.1/lib/net/ssh/authentication/methods/0000755000004100000410000000000013641340536022522 5ustar www-datawww-datanet-ssh-krb-0.5.1/lib/net/ssh/authentication/methods/gssapi_with_mic.rb0000644000004100000410000001027613641340536026226 0ustar www-datawww-datarequire 'net/ssh/authentication/methods/abstract' require 'net/ssh/kerberos/constants' require 'gssapi' module Net module SSH module Authentication module Methods # Implements the Kerberos 5 SSH authentication method. class GssapiWithMic < Abstract include Net::SSH::Kerberos::Constants # Attempts to perform gssapi-with-mic Kerberos authentication def authenticate(next_service, username, password=nil) gss = nil # Try to start gssapi-with-mic authentication. debug { "trying kerberos authentication" } req = userauth_request(username, next_service, "gssapi-with-mic") req.write_long(1) supported_oid = (6.chr + GSS_KRB5_MECH.length.chr + GSS_KRB5_MECH).force_encoding(Encoding::ASCII_8BIT) req.write_string(supported_oid) send_message req message = session.next_message case message.type when USERAUTH_GSSAPI_RESPONSE debug { "gssapi-with-mic proceeding" } when USERAUTH_FAILURE info { "gssapi-with-mic failed (USERAUTH_FAILURE)" } return false else raise Net::SSH::Exception, "unexpected server response to USERAUTH_REQUEST: #{message.type} (#{message.inspect})" end # Try to match the OID. oid = message.read_string.force_encoding(Encoding::ASCII_8BIT) if oid != supported_oid info { "gssapi-with-mic failed (USERAUTH_GSSAPI_RESPONSE)" } return false end # Try to complete the handshake. gss = GSSAPI::Simple.new hostname established = false debug { "gssapi-with-mic handshaking" } until established # :delegate => true always forwards tickets. This may or may not be a good idea, and should really be a user-specified option. token = gss.init_context(token, :delegate => true) break if token === true if token && token.length > 0 send_message Net::SSH::Buffer.from(:byte, USERAUTH_GSSAPI_TOKEN, :string, token) message = session.next_message case message.type when USERAUTH_GSSAPI_ERROR message = session.next_message message.get_long message.get_long info { "gssapi-with-mic error (USERAUTH_GSSAPI_ERROR) (#{message.read_string})" } when USERAUTH_GSSAPI_ERRTOK message = session.next_message info { "gssapi-with-mic error (USERAUTH_GSSAPI_ERRTOK) (#{message.read_string})" } when USERAUTH_FAILURE info { "gssapi-with-mic failed (USERAUTH_FAILURE)" } return false end token = message.read_string end end # Attempt the actual authentication. debug { "gssapi-with-mic authenticating" } mic = gss.get_mic Net::SSH::Buffer.from(:string, session_id, :byte, USERAUTH_REQUEST, :string, username, :string, next_service, :string, "gssapi-with-mic").to_s if mic.nil? info { "gssapi-with-mic failed (context#get_mic)" } return false end send_message Net::SSH::Buffer.from(:byte, USERAUTH_GSSAPI_MIC, :string, mic) message = session.next_message case message.type when USERAUTH_SUCCESS info { "gssapi-with-mic success" } return true when USERAUTH_FAILURE info { "gssapi-with-mic partial failure (USERAUTH_FAILURE)" } return false else raise Net::SSH::Exception, "unexpected server response to USERAUTH_REQUEST: #{message.type} (#{message.inspect})" end end private # Returns the hostname as reported by the underlying socket. def hostname session.transport.host end end end end end end net-ssh-krb-0.5.1/lib/net/ssh/kerberos/0000755000004100000410000000000013641340536017654 5ustar www-datawww-datanet-ssh-krb-0.5.1/lib/net/ssh/kerberos/constants.rb0000644000004100000410000000165413641340536022223 0ustar www-datawww-datamodule Net; module SSH; module Kerberos module Constants # GSSAPI Key exchange method specific messages KEXGSS_INIT = 30 KEXGSS_CONTINUE = 31 KEXGSS_COMPLETE = 32 KEXGSS_HOSTKEY = 33 KEXGSS_ERROR = 34 KEXGSS_GROUPREQ = 40 KEXGSS_GROUP = 41 # GSSAPI User authentication method specific messages USERAUTH_GSSAPI_RESPONSE = 60 USERAUTH_GSSAPI_TOKEN = 61 USERAUTH_GSSAPI_EXCHANGE_COMPLETE = 63 USERAUTH_GSSAPI_ERROR = 64 USERAUTH_GSSAPI_ERRTOK = 65 USERAUTH_GSSAPI_MIC = 66 # GSSAPI constant OID(s) GSS_KRB5_MECH = "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" GSS_KRB5_MECH_USER2USER = "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x03" end end; end; end net-ssh-krb-0.5.1/lib/net/ssh/kerberos.rb0000644000004100000410000000023413641340536020200 0ustar www-datawww-datarequire 'net/ssh' require 'net/ssh/errors' module Net; module SSH; module Kerberos end; end; end require 'net/ssh/authentication/methods/gssapi_with_mic' net-ssh-krb-0.5.1/Gemfile0000644000004100000410000000006413641340536015202 0ustar www-datawww-datasource 'http://rubygems.org' gemspec gem 'gssapi' net-ssh-krb-0.5.1/example/0000755000004100000410000000000013641340536015342 5ustar www-datawww-datanet-ssh-krb-0.5.1/example/Capfile0000644000004100000410000000021113641340536016622 0ustar www-datawww-datarequire 'net/ssh/kerberos' set :ssh_options, { :auth_methods => %w(gssapi-with-mic publickey hostbased password keyboard-interactive) } net-ssh-krb-0.5.1/example/sspi.rb0000644000004100000410000000471713641340536016656 0ustar www-datawww-data#$DEBUG = 1 require 'socket' require 'rubygems' gem 'net-ssh' $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'net/ssh' require 'net/ssh/errors' require 'net/ssh/kerberos' unless Net::SSH::Kerberos::Drivers.available.include? 'SSPI' $stderr.puts "No drivers supporting SSPI could be loaded." exit 1 end include Net::SSH::Kerberos::Drivers::SSPI include Net::SSH::Kerberos::Constants result = API.querySecurityPackageInfo "Kerberos", nil if result.ok? pkg_info = API._args_[1] $stderr.puts "querySecurityPackageInfo: (#{result}) #{pkg_info.comment} (max_token=#{pkg_info.max_token})" @max_token = pkg_info.max_token result = API.freeContextBuffer pkg_info.to_ptr $stderr.puts "freeContextBuffer: (#{result})" else $stderr.puts "querySecurityPackageInfo: (#{result})" end result = API.acquireCredentialsHandle nil, "Kerberos", SECPKG_CRED_OUTBOUND, nil, nil, nil, nil, creds=API::SecHandle.malloc, ts=API::TimeStamp.malloc if result.ok? $stderr.puts "acquireCredentialsHandle: (#{result})" begin result = API.queryCredentialsAttributes creds, SECPKG_ATTR_NAMES, nil if result.ok? names = API._args_[2] $stderr.puts "queryCredentialsAttributes: (#{result}) #{names.to_s}" result = API.freeContextBuffer names $stderr.puts "freeContextBuffer: (#{result})" output = API::SecBufferDesc.create @max_token if $DEBUG $stderr.puts "SecBufferDesc.create: #{output.inspect} => #{output.buffer(0).inspect} => #{output.buffer(0).data.inspect}" end result = API.initializeSecurityContext creds, nil, 'host/'+Socket.gethostbyname('localhost')[0], ISC_REQ_DELEGATE | ISC_REQ_MUTUAL_AUTH | ISC_REQ_INTEGRITY, 0, SECURITY_NATIVE_DREP, nil, 0, ctx=API::SecHandle.malloc, output, 0, ts=API::TimeStamp.malloc if result.ok? $stderr.puts "initializeSecurityContext: (#{result}) ctx=#{! ctx.nil?} token.length=#{output.buffer(0).length}" result = API.deleteSecurityContext ctx $stderr.puts "deleteSecurityContext: (#{result})" else $stderr.puts "initializeSecurityContext: (#{result})" end else $stderr.puts "queryCredentialsAttributes: (#{result})" end ensure result = API.freeCredentialsHandle creds $stderr.puts "freeCredentialsHandle : (#{result})" end else $stderr.puts "acquireCredentialsHandle: (#{result})" end net-ssh-krb-0.5.1/example/gss.rb0000644000004100000410000000653113641340536016470 0ustar www-datawww-datarequire 'socket' require 'rubygems' gem 'net-ssh' $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'net/ssh' require 'net/ssh/errors' require 'net/ssh/kerberos' unless Net::SSH::Kerberos::Drivers.available.include? 'GSS' $stderr.puts "No drivers supporting GSSAPI could be loaded." exit 1 end include Net::SSH::Kerberos::Drivers::GSS include Net::SSH::Kerberos::Constants result = API.gss_acquire_cred nil, 60, nil, GSS_C_INITIATE, nil, nil, 0 if result.ok? creds = API._args_[4] $stderr.puts "gss_acquire_cred: (#{result}) => #{creds.to_i}" begin result = API.gss_inquire_cred creds, nil, 0, 0, nil if result.ok? name, oids = API._args_[1], API._args_[4] $stderr.puts "gss_inquire_cred: (#{result}) #{oids.inspect}" begin result = API.gss_display_name name, buffer=API::GssBuffer.malloc, nil if result.ok? oid = API._args_[2] $stderr.puts "gss_display_name: (#{result}) #{buffer} #{oid.inspect}" result = API.gss_release_buffer buffer $stderr.puts "gss_release_buffer: (#{result})" else $stderr.puts "gss_display_name failed : (#{result})" end ensure result = API.gss_release_oid_set oids $stderr.puts "gss_release_oid_set: (#{result})" result = API.gss_release_name name $stderr.puts "gss_release_name: (#{result})" end else $stderr.puts "gss_inquire_cred failed: (#{result})" end target_name = 'host@'+Socket.gethostbyname(`hostname || echo "localhost"`.strip)[0] buffer = API::GssBuffer.malloc buffer.value = target_name buffer.length = target_name.length API.gss_import_name buffer, GSS_C_NT_HOSTBASED_SERVICE, nil if result.ok? target = API._args_[2] $stderr.puts "gss_import_name: (#{result}) #{target.to_i}" begin result = API.gss_display_name target, buffer, nil if result.ok? oid = API._args_[2] $stderr.puts "gss_display_name: (#{result}) #{buffer} #{oid.inspect}" result = API.gss_release_buffer buffer $stderr.puts "gss_release_buffer: (#{result})" else $stderr.puts "gss_display_name failed : (#{result})" end result = API.gss_init_sec_context creds, GSS_C_NO_CONTEXT, target, GSS_C_KRB5, GSS_C_DELEG_FLAG | GSS_C_MUTUAL_FLAG | GSS_C_INTEG_FLAG, 60, GSS_C_NO_CHANNEL_BINDINGS, GSS_C_NO_BUFFER, nil, buffer, 0, 0 if result.ok? context, actual_mech = API._args_[1], API._args_[8] $stderr.puts "gss_init_sec_context: (#{result}) token.length=#{buffer.length}, #{actual_mech.inspect}" result = API.gss_release_buffer buffer $stderr.puts "gss_release_buffer: (#{result})" result = API.gss_delete_sec_context context, nil $stderr.puts "gss_delete_sec_context: (#{result})" else $stderr.puts "gss_init_sec_context failed : (#{result})" end ensure result = API.gss_release_name target $stderr.puts "gss_release_name: (#{result})" end else $stderr.puts "gss_import_name failed: (#{result})" end ensure result = API.gss_release_cred creds $stderr.puts "gss_release_cred: (#{result})" end else $stderr.puts "gss_acquire_cred failed: (#{result})" end