I am trying to bootstrap a node, bento/centos 7.2, via Chef and am running into an SSH error.
I have virtualbox installed along with vagrant. I am able to ssh into the vm without issue using the ssh client built-in to the Chef DK. I am using Hosted Chef as my server.
On my Win 10 workstation, I issue the following command and get an error.
PS C:\Users\Topher\Documents\Learn Chef\.chef> knife bootstrap 10.0.2.15 --ssh-user vagrant --sudo --ssh-identity-file C:\Users\
Topher\.vagrant\machines\default\virtualbox\private_key --node-name localhost --run-list 'recipe[learn_chef_httpd]'
Node localhost exists, overwrite it? (Y/N) Y
Client localhost exists, overwrite it? (Y/N) Y
Creating new client for localhost
Creating new node for localhost
Connecting to 10.0.2.15
ERROR: Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout
Any ideas what is causing the ConnectionTimeout?
In my case I was trying to bootstrap a remote server (not a local Vagrant VM) using knife as follows:
knife bootstrap <FQDN of node being provisioned> -x <username> -P <password> --sudo --use-sudo-password <password> -N <name for node being provisioned>
In my case the problem was that my Chef Server was running as a local VM and it was using a VirtualBox private network and was therefor not accessible to the node I was provisioning using knife. By changing my Vagrant config for my Chef Server to a public bridge network I was able to get past the "ERROR: Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout" during my knife bootstrap command. Here is what my Vagrant file change looked like:
Vagrant.configure(2) do |config|
config.vm.define 'chef-server' do |cs|
cs.vm.box = 'bento/ubuntu-14.04'
cs.vm.box_version = '2.2.9'
cs.vm.hostname = 'chef-server.test'
#cs.vm.network 'private_network', ip: 'xxx.16.9.5'
cs.vm.network "public_network",
bridge: "Intel(R) Ethernet Connection I217-LM",
ip: ENV.fetch("IPS", "xxx.16.9.5"), netmask: ENV.fetch("NETMASKS", "255.255.0.0")
cs.vm.provision 'shell', inline: CHEF_SERVER_SCRIPT.dup
set_hostname(cs)
cs.vm.provider 'virtualbox' do |v|
v.memory = 2048
v.cpus = 2
end
end
Note the commented out private network and the uncommented public network immediately after it.
One useful command line arg for knife is -VV for verbose / debug output. Try that to see if it gives you more insight into your problem.
One other thing I noticed is that in my case I would sometimes the "ERROR: Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout" during my knife bootstrap command but on retry it would succeed.
Please mark my answer as the correct answer if it solves your problem.
Related
I was trying to deploy 4 vagrant box of two different OS. two of them are Ubuntu and other two are Centos. My vagrant file configuration is below:-
config.vm.define "ubuntu" do |ubuntu|
ubuntu.vm.hostname="ubuntu"
ubuntu.vm.box="bento/ubuntu-17.10"
ubuntu.vm.network "private_network", ip:"192.168.33.10"
end
config.vm.define "centos" do |centos|
centos.vm.hostname="centos"
centos.vm.box="bento/centos-7.4"
centos.vm.network "private_network", ip:"192.168.33.20"
end
config.vm.define "server1" do |server1|
server1.vm.hostname="server1"
server1.vm.box="bento/ubuntu-17.10"
server1.vm.network "private_network", ip:"192.168.33.30"
end
config.vm.define "server2" do |server2|
server2.vm.hostname="server2"
server2.vm.box="bento/centos-7.4"
server2.vm.network "private_network", ip:"192.168.33.40"
end
After successfully executing executing vagrant up I checked the vagrant status and found all box were running ok.
ubuntu running (virtualbox)
centos running (virtualbox)
server1 running (virtualbox)
server2 running (virtualbox)
however when I tried to login to each machine using vagrant ssh ubuntu , vagrant ssh centos , vagrant ssh server1 ,vagrant ssh server2 commands , every machine could be logged in except server1. While I tried to access server2 using vagrant ssh server1 that error showed:-
"ssh_exchange_identification: read: Connection reset by peer"
I using vagrant 2.2.4 on my elementary OS Loki system. Seeking help from experienced.TIA
The issue has solved. I dont no what was wrong actually! However, I tried following simple steps and fortunately it worked: 1. vagrant destroy 2. vagrant up
I am trying to connect to a remote lisp, which is running on a virtual machine on my laptop. In the slime manual, I found this line
there is a way to connect without an ssh tunnel, but it has the side-effect of giving the entire world access to your lisp image, so we’re not going to talk about it
This seems a bit dated. I would imagine that running the lisp on a virtual machine will not allow any one else to access the lisp.
My question is, how do I connect to a remote lisp without SSH?
[EDIT]
I have seen the question here, but when I forward the port, slime is not able to connect to swank and gives me the following error
Lisp connection closed unexpectedly: connection broken by remote peer
You could use quicklisp and swank in the virtual machine then forward the port you open the lisp following this tutorial or the one for the environment you use for virtualization.
In your lisp on the virtual machine:
Welcome to Clozure Common Lisp Version 1.11-r16635 (DarwinX8664)!
CCL is developed and maintained by Clozure Associates. For more information
about CCL visit http://ccl.clozure.com. To enquire about Clozure's Common Lisp
consulting services e-mail info#clozure.com or visit http://www.clozure.com.
? (ql:quickload :swank)
To load "swank":
Load 1 ASDF system:
swank
; Loading "swank"
.....
(:SWANK)
? (swank:create-server)
;; Swank started at port: 4005.
4005
?
then use slime-connect to connect to your virtual machine ip and the port you choose for the swank-server.
In other case for ssh is also easy.if you want to connect to one port in one remote machine using ssh the easy way is using the -L option like this
ssh user#ip -p22 -L local_port:localhost:remote_port
then you use slime-connect and connect to localhost and the local_port
This is a setup using vagrant, only connect to ssh to the machine to startup swank, but you can automatize it.
1) Vagrantfile: with the forwarding port and the ip, and the roswell setup, you can install directly sbcl, it is not important but with roswell is easy to get lisp up and running in a minute, the important thing here is having quicklisp running.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 4005, host: 4005
config.vm.network "private_network", ip: "192.168.33.24"
config.vm.provider "virtualbox" do |vb|
vb.name = "lisp_host"
vb.gui = false
vb.memory = "1024"
end
config.vm.provision "shell",
inline: "apt-get update
if which apt-get > /dev/null; then sudo apt-get -y install git build-essential automake libcurl4-openssl-dev;fi
git clone -b release https://github.com/roswell/roswell.git
cd roswell
sh bootstrap
./configure
make
sudo make install
sudo ros setup"
# SHELL
end
2) vagrant up amd vagrant ssh to go inside the machine
3) ros run -Q #after installing the sbcl you can use quicklisp in the REPL
4) Preparing swank
2016-06-06 12:32:55 ☆ |ruby-2.2.3#laguna| Antonios-MBP in ~/learn/lisp/stackoverflow/vagrant-env
○ → vagrant ssh
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-79-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Mon Jun 6 10:26:56 UTC 2016
System load: 0.41 Processes: 84
Usage of /: 4.7% of 39.34GB Users logged in: 0
Memory usage: 12% IP address for eth0: 10.0.2.15
Swap usage: 0% IP address for eth1: 192.168.33.24
Graph this data and manage this system at:
https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
Last login: Mon Jun 6 10:26:56 2016 from 10.0.2.2
vagrant#vagrant-ubuntu-trusty-64:~$ ros run -Q
WARNING: Setting locale failed.
Check the following variables for correct values:
LC_CTYPE=UTF-8
LANG=en_US.UTF-8
* (ql:quickload :swank)
To load "swank":
Load 1 ASDF system:
swank
; Loading "swank"
.
(:SWANK)
* (setf swank::*loopback-interface* "192.168.33.24") ;Important to listen throught the internet IP
"192.168.33.24"
* (swank:create-server)
;; Swank started at port: 4005.
4005
5) Then go to you emacs environment:
slime-connect
host 192.168.33.24
port 4005
6) maybe the version is different accept it and go on
Finally you can use it
I believe that this tricks could work for you the most important is the swank::loopback-interface
I am trying to set up Vagrant for my development environment, but are having problems getting Vagrant to automatically connect to a remote server on startup
In my Vagrantfile I have the following line:
config.vm.provision "shell", path: "vagrant/startup.sh", run: "always"
In my startup.sh I have the following:
#!/usr/bin/env bash
sshpass -p '*******' ssh -fN -L 389:XXX.XXX.XXX.XXX:389 ******#********.*******.**.**
The provision runs on startup, but no ports are getting forwarded
If I SSH into the box and run the command, it just returns without any errors, but doesn't work. I can only get it to work if I don't use sshpass
P.S. Please don't tell me about the insecurity of sshpass, this is only used for LAN connections
I currently use Vagrant and Chef to provision a VM and setup my PHP based project. This includes running composer install which essentially does a git clone of a number of private repositories.
After setting up ssh agent forwarding as outlined in the docs and the answers here: How to use ssh agent forwarding with "vagrant ssh"? I have successfully got it working.
The problem I'm having is when ever I boot a VM, provision a VM or SSH into a VM I'm now asked for vagrants default password, see examples below:
==> web: Waiting for machine to boot. This may take a few minutes...
web: SSH address: 192.168.77.185:22
web: SSH username: vagrant
web: SSH auth method: private key
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
vagrant#192.168.77.185's password:
Example 2
➜ vagrant git:(master) ✗ vagrant ssh
vagrant#192.168.77.185's password:
This is pretty inconvenient as I work across a number of projects, including destroying and creating some a number of times a day (Chef test kitchen). Is there anyway to automatically use my public key as well so I don't need to continually enter a password?
I ran into a similar issue recently after creating a new Vagrant box from scratch. The problem turned out to be old entries in ~/.ssh/known_hosts (on OS X).
Try the following (assumes OS X or linux):
ssh into your Vagrant machine
type ip addr or ifconfig or the like (depending on your OS)
take note of the IP addresses listed, including 127.0.0.1
on your host machine, run ssh-keygen -R {vm-ip-address} (make sure to include 127.0.0.1 and [127.0.0.1]) for the addresses in step 3
confirm the relevant entries have been removed from ~/.ssh/known_hosts
vagrant reload
vagrant ssh
Alternatively, you can just delete/move/rename the ~/.ssh/known_hosts file, though this will require reconfirming authenticity again for multiple machines you've already ssh'd to.
I hope that helps.
Reference: http://www.geekride.com/ssh-warning-remote-host-identification-has-changed/
Whenever I try to connect to my local Vagrant, I get this error when I run ssh vagrant#127.0.0.1:2222 from the Windows git bash:
ssh: connect to host 127.0.0.1:2222 port 22: Bad file number
It was working previously, so I'm not sure what could have caused this. When I try to do an SFTP connection in PHPStorm 8, I get this error:
Connection to '127.0.0.1' failed.
SSH_MSG_DISCONNECT: 2 Too many authentication failures for vagrant
I've tried vagrant destroy with vagrant box remove laravel/homestead and then recreating the box from a backup I had that previously worked using vagrant box add laravel/homestead homestead.box but I still get the same errors.
I'm on Windows 7.
What can I do to get access to my vagrant box commandline again?
Try command:
ssh -p 2222 vagrant#127.0.0.1
The answer by outboundexplorer above is the correct one I believe.Here is my step-by-step approach on how I did this:
Step 1: Find out exactly what SSH settings to use
Ensure the vagrant box is running (you've done vagrant up that is)
From the command line, go to your project directory (the one where the Vagrantfile is located) and run vagrant ssh-config.
You'll get an output like this:
Host default
HostName 127.0.0.1
User ubuntu
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Projects/my-test-project/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
Step 2: Setting up PHPStorm to SFTP to the Vagrant box
Based on the config settings shown above, I set up the following SFTP remote deployment server:
SFTP host: 127.0.0.1
Port: 2222
Root path: /home/ubuntu/my-test-project (this is the folder inside the Vagrant box where the files will be uploaded to, change to whatever suits your needs)
User name: ubuntu
Auth type: Select "Key pair (OpenSSH or PuTTY)"
Private key file: Point to the IdentityFile path shown (C:/Projects/....)
... and that was it.
I got this same failure when using PHpStorm to SSH into the VirtualBox guest machine that i had set up with Vagrant. Everything worked fine before I upgraded to Windows 10. After upgrading, first of all i had to upgrade to VirtualBox and Vagrant latest versions to get everything to work on Windows 10.
But then i couldn't ssh into the guest machine using the PhpStorm ssh client. After much reading, everything seemed to suggest that I had too many ssh-keys installed on my Windows machine, but checking regedit just showed that I only had a couple of keys which should be less than the suggested max 5 keys (as default). In the end i did vagrant ssh which didn't allow me to ssh into the guest machine, but it did reconfirm the ssh details for me. I then realized that after all the new installs it didn't want me to use the C:\Users\Andy\.vagrant.d\insecure_private_key key but instead use a key that it had placed within the project itself at C:/Users/Andy/CodeLab5/vagrant/.vagrant/machines/default/virtualbox/private_key.
Everything is working as it should again now :)
Make sure your vagrant is up and running by command : vagrant up
and then do vagrant ssh. It will connect to vagrant localhost