Can't connect via "vagrant ssh" to vagrant box created with "vagrant package" - vagrant

A vagrant box which was created using "vagrant package" cannot be connected to using "vagrant ssh".
Note - I am using libvirt and QEMU, not Virtualbox.
I took a working vagrant instance and created a vagrant box using
vagrant package --output abc.box
vagrant box add abc.box --name abc
I then created an empty directory and generated the Vagrantfile using
vagrant init
I edited the Vagrantfile and set config.vm.box = "abc"
I then tried a "vagrant up", and it hangs on the SSH connection
I ran a "vagrant -ssh-config" which returns settings. I was able to use the IP and key listed there to connect to the instance.
Can anybody tell me what the correct process is for getting this kind of instance to start properly? Is it by design that the insecure access isn't preserved in the packaged box? Should I just be installing my own SSH keys and logging in using "ssh" instead of "vagrant ssh"?
I expected the "vagrant up" to complete, but it never returned the prompt. Attempts to connect to it using "vagrant ssh" from another terminal didn't work.
I turned on debugging and saw the log entries listed below.
DEBUG ssh: == Net-SSH connection debug-level log START ==
DEBUG ssh: D, [2019-09-03T18:00:51.803268 #4837] DEBUG -- net.ssh.transport.session[1ae7be8]: establishing connection to 192.168.121.230:22
D, [2019-09-03T18:00:51.804016 #4837] DEBUG -- net.ssh.transport.session[1ae7be8]: connection established
I, [2019-09-03T18:00:51.804202 #4837] INFO -- net.ssh.transport.server_version[1ae6e64]: negotiating protocol version
D, [2019-09-03T18:00:51.804260 #4837] DEBUG -- net.ssh.transport.server_version[1ae6e64]: local is `SSH-2.0-Ruby/Net::SSH_4.2.0 x86_64-linux'
D, [2019-09-03T18:00:51.814838 #4837] DEBUG -- net.ssh.transport.server_version[1ae6e64]: remote is `SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3'
I, [2019-09-03T18:00:51.815157 #4837] INFO -- net.ssh.transport.algorithms[1adcbe4]: sending KEXINIT
D, [2019-09-03T18:00:51.815403 #4837] DEBUG -- socket[1ae792c]: queueing packet nr 0 type 20 len 1156
D, [2019-09-03T18:00:51.815504 #4837] DEBUG -- socket[1ae792c]: sent 1160 bytes
DEBUG ssh: == Net-SSH connection debug-level log END ==
INFO retryable: Retryable exception raised: #<Errno::ECONNRESET: Connection reset by peer - recvfrom(2)>
INFO ssh: Attempting to connect to SSH...
INFO ssh: - Host: 192.168.XXX.XXX
INFO ssh: - Port: 22
INFO ssh: - Username: vagrant
INFO ssh: - Password? false
INFO ssh: - Key Path: ["/home/XXXXX/.vagrant.d/insecure_private_key"]
DEBUG ssh: - connect_opts: {:auth_methods=>["none", "hostbased", "publickey"], :config=>false, :forward_agent=>false, :send_env=>false, :keys_only=>true, :verify_host_key=>false, :password=>nil, :port=>22, :timeout=>15, :user_known_hosts_file=>[], :verbose=>:debug, :encryption=>["aes128-cbc", "3des-cbc", "blowfish-cbc", "cast128-cbc", "aes192-cbc", "aes256-cbc", "rijndael-cbc#lysator.liu.se", "idea-cbc", "arcfour128", "arcfour256", "arcfour", "aes128-ctr", "aes192-ctr", "aes256-ctr", "cast128-ctr", "blowfish-ctr", "3des-ctr", "none"], :logger=>#<Logger:0x00000000034d08c0 #level=0, #progname=nil, #default_formatter=#<Logger::Formatter:0x00000000034d0848 #datetime_format=nil>, #formatter=nil, #logdev=#<Logger::LogDevice:0x00000000034d07f8 #shift_period_suffix=nil, #shift_size=nil, #shift_age=nil, #filename=nil, #dev=#<StringIO:0x00000000034d0938>, #mon_owner=nil, #mon_count=0, #mon_mutex=#<Thread::Mutex:0x00000000034d07a8>>>, :keys=>["/home/XXXXXX/.vagrant.d/insecure_private_key"]}```

Related

remote ssh -> access vagrant on wsl 2 error

I want to access folders in vagrant(on wsl2) from VScode windows(host)
Windows
-- WSL 2
-- vagrnat
I copied 'vagrant ssh-config' into '.ssh/config'
my 'config'
Host host
HostName host
IdentityFile C:\path\to\key
User user
Host vagrant
HostName 172.31.32.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /mnt/c/Users/Mike/projects/lighthouse/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
and the output is
[13:57:11.814] Log Level: 2
[13:57:11.815] remote-ssh#0.76.1
[13:57:11.815] win32 x64
[13:57:11.819] SSH Resolver called for “ssh-remote+vagrant”, attempt 1
[13:57:11.820] “remote.SSH.useLocalServer”: false
[13:57:11.820] “remote.SSH.showLoginTerminal”: false
[13:57:11.820] “remote.SSH.remotePlatform”: {}
[13:57:11.820] “remote.SSH.path”: undefined
[13:57:11.820] “remote.SSH.configFile”: C:\Users\Mike.ssh\config
[13:57:11.820] “remote.SSH.useFlock”: true
[13:57:11.820] “remote.SSH.lockfilesInTmp”: false
[13:57:11.821] “remote.SSH.localServerDownload”: auto
[13:57:11.821] “remote.SSH.remoteServerListenOnSocket”: false
[13:57:11.821] “remote.SSH.showLoginTerminal”: false
[13:57:11.821] “remote.SSH.defaultExtensions”: []
[13:57:11.821] “remote.SSH.loglevel”: 2
[13:57:11.821] “remote.SSH.enableDynamicForwarding”: true
[13:57:11.821] “remote.SSH.enableRemoteCommand”: false
[13:57:11.821] “remote.SSH.serverPickPortsFromRange”: {}
[13:57:11.821] “remote.SSH.serverInstallPath”: {}
[13:57:11.841] SSH Resolver called for host: vagrant
[13:57:11.841] Setting up SSH remote “vagrant”
[13:57:11.861] Using commit id “c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1” and quality “stable” for server
[13:57:11.864] Install and start server if needed
[13:57:13.663] Checking ssh with “ssh -V”
[13:57:13.697] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
[13:57:13.702] Using SSH config file “C:\Users\Mike.ssh\config”
[13:57:13.702] Running script with connection command: ssh -T -D 64189 -F “C:\Users\Mike.ssh\config” vagrant bash
[13:57:13.704] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[13:57:13.921] > e]0;C:\WINDOWS\System32\cmd.exea
[13:57:13.921] Got some output, clearing connection timeout
[13:57:13.947] > vagrant#172.31.32.1: Permission denied (publickey,password).
[13:57:13.956] > 프로세스에서 없는 파이프에 쓰려고 했습니다.
[13:57:15.208] “install” terminal command done
[13:57:15.209] Install terminal quit with output: 프로세스에서 없는 파이프에 쓰려고 했습니다.
[13:57:15.209] Received install output: 프로세스에서 없는 파이프에 쓰려고 했습니다.
[13:57:15.209] Failed to parse remote port from server output
[13:57:15.210] Resolver error: Error:
at Function.Create (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:586041)
at Object.t.handleInstallOutput (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:584693)
at Object.t.tryInstall (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:681846)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:644486
at async Object.t.withShowDetailsEvent (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:647831)
at async Object.t.resolve (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:645565)
at async c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:722872
[13:57:15.216] ------
I tried
'ssh user#vagrant'
: user#IP addr: Permission denied (publickey,password)
remote-ssh:kill vs code server on host..
remote-ssh:uninstall vs code server on host..
checked remote.ssh:config file PATH in vscode remote-ssh settings
don't exist 'known_hosts' in .ssh folder(hidden file checked)
tried solutions from searching I found, but still stuck here.

Vscode SSH Jump Failed with macOS

I can connect to the first server with key but cannot connet to the second server jumping with the first server. I doubt it is a bug on MacOS because I can jump to the seceond server with command line. Is there ANYONE knows what happened here?
Here is the config:
Host comp
HostName xx.xx.xxx.xxx
User xxxx
Port 22
IdentityFile ***************
Host local
HostName 127.0.0.1
Port ****
User xxxx
ProxyCommand ssh -q -x -W %h:%p comp
IdentityFile ***************
Here is the error information:
[19:55:48.660] Log Level: 2
[19:55:48.662] remote-ssh#0.55.0
[19:55:48.662] darwin x64
[19:55:48.663] SSH Resolver called for "ssh-remote+localhost", attempt 1
[19:55:48.663] SSH Resolver called for host: localhost
[19:55:48.663] Setting up SSH remote "localhost"
[19:55:48.669] Acquiring local install lock: /var/folders/5q/****************_tr0000gn/T/vscode-remote-ssh-localhost-install.lock
[19:55:48.713] Looking for existing server data file at /Users/gy/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-localhost-************************************-0.55.0/data.json
[19:55:48.742] Using commit id "***********************************" and quality "stable" for server
[19:55:48.743] Install and start server if needed
[19:55:48.779] Checking ssh with "ssh -V"
[19:55:48.854] > OpenSSH_8.1p1, LibreSSL 2.7.3
[19:55:48.860] Using SSH config file "/Users/gy/.ssh/config/vscodeconfig"
[19:55:48.861] askpass server listening on /var/folders/5q/******************_tr0000gn/T/vscode-ssh-askpass-**********************************.sock
[19:55:48.862] Spawning local server with {"ipcHandlePath":"/var/folders/5q/**************_tr0000gn/T/vscode-ssh-askpass-********************************.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","54815","-o","ConnectTimeout=15","-F","/Users/gy/.ssh/config/vscodeconfig","localhost"],"dataFilePath":"/Users/gy/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-localhost-*********************************-0.55.0/data.json"}
[19:55:48.862] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer)","VSCODE_SSH_ASKPASS_MAIN":"/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/5q/********************_tr0000gn/T/vscode-ssh-askpass-**********************************.sock"}
[19:55:48.871] Spawned 34492
[19:55:48.987] > local-server> Spawned ssh: 34493
[19:55:49.008] stderr> OpenSSH_8.1p1, LibreSSL 2.7.3
[19:55:50.129] stderr> kex_exchange_identification: Connection closed by remote host
[19:55:50.131] > local-server> ssh child died, shutting down
[19:55:50.136] Local server exit: 0
[19:55:50.136] Received install output: OpenSSH_8.1p1, LibreSSL 2.7.3
kex_exchange_identification: Connection closed by remote host
[19:55:50.137] Stopped parsing output early. Remaining text: OpenSSH_8.1p1, LibreSSL 2.7.3kex_exchange_identification: Connection closed by remote host
[19:55:50.137] Failed to parse remote port from server output
[19:55:50.141] Resolver error: Error:
at Function.Create (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:1:130564)
at Object.t.handleInstallOutput (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:1:127671)
at Object.t.tryInstallWithLocalServer (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:102339)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async /Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:104310
at async Object.t.withShowDetailsEvent (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:109845)
at async /Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:100912
at async R (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:97702)
at async Object.t.resolveWithLocalServer (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:100561)
at async Object.t.resolve (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:107840)
at async /Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:141955
[19:55:50.143] ------
Could someone enlighten me on the reason for the problem or on a possible solution ? Thanks !
I have the similar problem.
Later it disappears after I turn off the agent server.
Maybe you can try this.

SSH and Vagrant

When i run vagrant up in my app the process gets stuck at
SSH auth method: private key
Vagrantfile
Vagrant.configure(2) do |config|
config.vm.define :touch_rugby do |app_config|
app_config.vm.box = "bento/ubuntu-16.04"
app_config.vm.host_name = "touchrugby"
app_config.vm.network "private_network", ip: "33.32.1.2"
app_config.ssh.insert_key = true
end
end
When running vagrant ssh-config in another window
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/rich/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
Where would the insecure_private_key come from? and should it not be a private_key
What can i look at to try and debug this? I ran vagrant up in debug mode and found this
INFO ssh: Attempting to connect to SSH...
INFO ssh:   - Host: 127.0.0.1
INFO ssh:   - Port: 2222
INFO ssh:   - Username: vagrant
INFO ssh:   - Password? false
INFO ssh:   - Key Path: ["/Users/rich/.vagrant.d/insecure_private_key"]
DEBUG ssh:   - connect_opts: {:auth_methods=> ["none "hostbased""publickey"],
:config=>false,
:forward_agent=>false,
:send_env=>false,
:keys_only=>true,
:paranoid=>false,
:password=>nil,
:port=>2222,
:timeout=>15 }
INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "1f000e35-eee4-482d-8f76-91082f19c2ab", "--machinereadable"]
Does anyone have any further ideas on what i can do?
Thanks
The private key that you see at /Users/rich/.vagrant.d/insecure_private_key is generated by vagrant, if the ssh.insert_key property is set to true.
Looking at the documentation, you should be able to specify the location to an existing private key using.
config.ssh.private_key_path
The path to the private key to use to SSH into the guest machine. By default this is the insecure private key that ships with Vagrant, since that is what public boxes use. If you make your own custom box with a custom SSH key, this should point to that private key.
Normally, Vagrant will automatically use a public, "well-known" ssh key and will automatically set the virtual box up to use that key. To get that behavior just don't set the app_config.ssh.insert_key = true option in your Vagrantfile.
We set these two options in our Vagrantfile because we don't use the default vagrant account but to better emulate our AWS environment we create an ec2-user account and specify our own private ssh key.
config.ssh.username = "ec2-user"
config.ssh.private_key_path = "/Users/lance/git/devops/.vagrant_helpers/vagrant_private_key"

Vagrant hangs on NFS mounting on Ubuntu 14.04

until today my vagrant setup was working nice and smooth. But something happened and I can't find out what.
All of a sudden when I do vagrant up it hangs on mounting the NFS shared folder.
My guess is that something broke due to some updates on my host. Below are the outputs from vagrant up --debug command and the list with the latest updates from the last 2 days.
Here's the output from vagrant:
==> default: Mounting NFS shared folders...
DEBUG ssh: Checking whether SSH is ready...
DEBUG ssh: Re-using SSH connection.
INFO ssh: SSH is ready!
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG guest: Searching for cap: mount_nfs_folder
DEBUG guest: Checking in: ubuntu
DEBUG guest: Checking in: debian
DEBUG guest: Checking in: linux
DEBUG guest: Found cap: mount_nfs_folder in linux
INFO guest: Execute capability: mount_nfs_folder [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "192.168.56.1", {"/home/vagrant"=>{:type=>:nfs, :mount_options=>["nolock,vers=3,udp,noatime,fsc,actimeo=1"], :guestpath=>"/home/vagrant", :hostpath=>"/home/stefan/NetBeansProjects/cargoplanning", :disabled=>false, :map_uid=>1000, :map_gid=>1000, :nfs_udp=>true, :nfs_version=>3, :uuid=>"2352560104", :linux__nfs_options=>["rw", "no_subtree_check", "all_squash", "anonuid=1000", "anongid=1000", "fsid=2352560104"]}}] (ubuntu)
DEBUG ssh: Checking whether SSH is ready...
DEBUG ssh: Re-using SSH connection.
INFO ssh: SSH is ready!
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG guest: Searching for cap: shell_expand_guest_path
DEBUG guest: Checking in: ubuntu
DEBUG guest: Checking in: debian
DEBUG guest: Checking in: linux
DEBUG guest: Found cap: shell_expand_guest_path in linux
INFO guest: Execute capability: shell_expand_guest_path [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "/home/vagrant"] (ubuntu)
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: echo; printf /home/vagrant (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG ssh: stdout:
/home/vagrant
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: mkdir -p /home/vagrant (sudo=true)
DEBUG ssh: stderr: stdin: is not a tty
DEBUG ssh: Exit status: 0
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: mount -o 'nolock,vers=3,udp,noatime,fsc,actimeo=1' 192.168.56.1:'/home/stefan/NetBeansProjects/cargoplanning' /home/vagrant (sudo=true)
DEBUG ssh: stderr: stdin: is not a tty
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
Try either to restart nfs service (sudo systemctl restart nfs-server.service for me in Arch) or to remove Vagrant entries from /etc/exports (they are surrounded with #VAGRANT-BEGIN: ... #VAGRANT-END: comments) and then to restart the service.
The problem was the udp protocol.
I removed udp from VagrantFile config line:
:mount_options => ['nolock,vers=3,udp,noatime,fsc,actimeo=1']
Also, udp is not recommended even if it's faster. https://github.com/mitchellh/vagrant/issues/2304
For anyone else still looking around and on 18.04, I found the culprit in my case.
It looks like in my case nfs-server package was missing even though nfs-kernel-server and nfs-common were installed, I installed nfs-server and vagrant up worked without an issue. Vagrant 2.0.3 and Virtualbox build 5.2.18_Ubuntu r123745

ssh: connect to host slave port 22: Connection timed out

Edited:-
i have done with single node cluster on two different machine,I have made one as master(192.168.1.1) and other m/c as slave(192.168.1.2), I am successfully able to ping between two machine,I have made the following changes to get into 2 node cluster Update :-
/etc/hosts on both machines hosts.allow
All : Ashish-PC 192.168.1.1 : allow
All : slave 192.168.1.2 : allow
master file with
Ashish-PC
slaves file with
Ashish-PC
slave
I am getting an error while copying local host public key to remote host(slave): port 22
ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop#slave
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: ssh: connect to host slave port 22: Connection timed out
as well as when i start all dfs at master services then also :-
bin/start-dfs.sh
starting namenode, logging to /usr/local/hadoop/libexec/../logs/hadoop-Ashish-namenode- Ashish-PC.out
slave: ssh: connect to host slave port 22: Connection timed out
Ashish-PC: starting secondarynamenode, logging to /usr/local/hadoop/libexec/../logs/hadoop-Ashish-secondarynamenode-Ashish-PC.out
slave: ssh: connect to host slave port 22: Connection timed out
while copying key:-
ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop#slave
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: ssh: connect to host slave port 22: Connection timed out
i have used cygwin and ssh is working fine on both the PC and I went through some suggestion to change the port number 22(because of ISP problem) but i dont want do that just because.
thanks in advance for your help and response.
Allow master to communicate through Windows Firewall by adding sshd in home as well as public...
make sure your sshd services are started on each node for communication.
This worked for me:
1.
sudo vi /etc/ssh/sshd_config
2.
Remove the comment
#Port 22
#Protocol 2

Resources