Merge pull request #13052 from soapy1/password-auth-ssh

Update connection settings when using a password to connect ssh
This commit is contained in:
Sophia Castellarin 2023-02-22 14:15:46 -08:00 committed by GitHub
commit bc1e00fc50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View File

@ -404,7 +404,7 @@ module VagrantPlugins
# Set some valid auth methods. We disable the auth methods that
# we're not using if we don't have the right auth info.
auth_methods = ["none", "hostbased"]
auth_methods = ["none", "hostbased", "keyboard-interactive"]
auth_methods << "publickey" if ssh_info[:private_key_path]
auth_methods << "password" if ssh_info[:password]
@ -461,6 +461,10 @@ module VagrantPlugins
connect_opts[:keepalive_interval] = 5
end
if ssh_info[:password]
connect_opts[:non_interactive] = true
end
@logger.info("Attempting to connect to SSH...")
@logger.info(" - Host: #{ssh_info[:host]}")
@logger.info(" - Port: #{ssh_info[:port]}")
@ -469,7 +473,7 @@ module VagrantPlugins
@logger.info(" - Key Path: #{ssh_info[:private_key_path]}")
@logger.debug(" - connect_opts: #{connect_opts}")
Net::SSH.start(ssh_info[:host], ssh_info[:username], connect_opts)
Net::SSH.start(ssh_info[:host], ssh_info[:username], **connect_opts)
ensure
# Make sure we output the connection log
@logger.debug("== Net-SSH connection debug-level log START ==")

View File

@ -664,7 +664,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
it "includes `none` and `hostbased` auth methods" do
expect(Net::SSH).to receive(:start).with(
nil, nil, hash_including(
auth_methods: ["none", "hostbased"]
auth_methods: ["none", "hostbased", "keyboard-interactive"]
)
).and_return(true)
communicator.send(:connect)
@ -780,7 +780,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
it "includes `publickey` auth method" do
expect(Net::SSH).to receive(:start).with(
anything, anything, hash_including(
auth_methods: ["none", "hostbased", "publickey"]
auth_methods: ["none", "hostbased", "keyboard-interactive", "publickey"]
)
).and_return(true)
communicator.send(:connect)
@ -809,7 +809,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
it "has password defined" do
expect(Net::SSH).to receive(:start).with(
anything, anything, hash_including(
password: 'vagrant'
password: 'vagrant', non_interactive: true
)
).and_return(true)
communicator.send(:connect)
@ -818,7 +818,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
it "includes `password` auth method" do
expect(Net::SSH).to receive(:start).with(
anything, anything, hash_including(
auth_methods: ["none", "hostbased", "password"]
auth_methods: ["none", "hostbased", "keyboard-interactive", "password"]
)
).and_return(true)
communicator.send(:connect)
@ -860,7 +860,7 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
it "includes `publickey` and `password` auth methods" do
expect(Net::SSH).to receive(:start).with(
anything, anything, hash_including(
auth_methods: ["none", "hostbased", "publickey", "password"]
auth_methods: ["none", "hostbased", "keyboard-interactive", "publickey", "password"]
)
).and_return(true)
communicator.send(:connect)

View File

@ -328,7 +328,7 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
it "includes `none` and `hostbased` auth methods" do
expect(Net::SSH).to receive(:start).with(
nil, nil, hash_including(
auth_methods: ["none", "hostbased"]
auth_methods: ["none", "hostbased", "keyboard-interactive"]
)
).and_return(connection)
communicator.send(:connect)
@ -420,7 +420,7 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
it "includes `publickey` auth method" do
expect(Net::SSH).to receive(:start).with(
anything, anything, hash_including(
auth_methods: ["none", "hostbased", "publickey"]
auth_methods: ["none", "hostbased", "keyboard-interactive", "publickey"]
)
).and_return(connection)
communicator.send(:connect)
@ -458,7 +458,7 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
it "includes `password` auth method" do
expect(Net::SSH).to receive(:start).with(
anything, anything, hash_including(
auth_methods: ["none", "hostbased", "password"]
auth_methods: ["none", "hostbased", "keyboard-interactive", "password"]
)
).and_return(connection)
communicator.send(:connect)
@ -500,7 +500,7 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
it "includes `publickey` and `password` auth methods" do
expect(Net::SSH).to receive(:start).with(
anything, anything, hash_including(
auth_methods: ["none", "hostbased", "publickey", "password"]
auth_methods: ["none", "hostbased", "keyboard-interactive", "publickey", "password"]
)
).and_return(connection)
communicator.send(:connect)