Re: [vagrant-up] ssh without "vagrant ssh"

15,589 views
Skip to first unread message

Olivier Raginel

unread,
Jun 10, 2012, 2:42:11 PM6/10/12
to vagra...@googlegroups.com
On Sun, Jun 10, 2012 at 09:30:48AM -0700, Suraj Gupta wrote:
> Is it possible to use plain-old-ssh to ssh into all VMs that have been
> started via 'vagrant up' and not 'vagrant ssh'? I'm using the tutorial
> - so the lucid32 box without any modification to my Vagrantfile(s).
> When I 'vagrant up' two or more virtual environments what are the
> hosts? ports? and what commands will provide that info?

vagrant ssh_config

--
Babar.

Nathan Fisher

unread,
Jun 11, 2012, 4:54:18 AM6/11/12
to vagra...@googlegroups.com
You can redirect that output into a file and use "ssh -C OUTFILE.TXT HOST".
--
Nathan Fisher
 m: +61 4 0641 8380

Nathan Fisher

unread,
Jun 11, 2012, 5:16:08 AM6/11/12
to vagra...@googlegroups.com
That should be -F not -C.

Suraj Gupta

unread,
Jun 11, 2012, 9:51:37 AM6/11/12
to vagra...@googlegroups.com
I piped the output of vagrant ssh-config to OUTFILE.txt and ran ssh -F.
is "HOST" a placeholder for localhost?

ssh -F OUTFILE.txt HOST
seems to nothing...as if bash is waiting for more commands

ssh -F OUTFILE.txt localhost
takes me down the route of ssh'ing into my own machine with the same user account, not vagrant

Suraj Gupta

unread,
Jun 14, 2012, 1:36:02 PM6/14/12
to vagra...@googlegroups.com
Ok, I got this to work by calling ssh with the info provided in OUTFILE.txt, instead of -F.
not sure why the file won't work as-is.

Olivier Raginel

unread,
Jun 14, 2012, 1:45:25 PM6/14/12
to vagra...@googlegroups.com
On Thu, Jun 14, 2012 at 10:36:02AM -0700, Suraj Gupta wrote:
> Ok, I got this to work by calling ssh with the info provided in
> OUTFILE.txt, instead of -F.
>
> not sure why the file won't work as-is.

OK, I guess I wasn't verbose enough. For ssh, what I normally use is the
following:

vagrant ssh_config | ssh -F /dev/stdin default

This also works with scp:
vagrant ssh_config | scp -F /dev/stdin default:some_file .

--
Babar.

John D. Hume

unread,
Jun 14, 2012, 6:31:13 PM6/14/12
to vagra...@googlegroups.com

It wasn't working because you weren't using the host alias ("default") in your command.

-- typed with my thumbs

Suraj Gupta

unread,
Jun 15, 2012, 10:07:21 AM6/15/12
to vagra...@googlegroups.com
Babar, John - thanks!  it worked!

John D. Hume

unread,
Aug 2, 2012, 8:33:11 AM8/2/12
to vagra...@googlegroups.com
That is what I meant. That form of the command works for me. I'm on a
machine w/o vagrant installed right now, but I happen to have a file
with the output of vagrant ssh_config handy, and this looks to me like
it would work if a vagrant box were up and running:

$ cat test/vagrant/vagrant.ssh.config | ssh -F /dev/stdin default
Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh: connect to host 127.0.0.1 port 2222: Connection refused

The file test/vagrant/vagrant.ssh.config contains this:
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/user/.vagrant.d/insecure_private_key
IdentitiesOnly yes

What output are you seeing? What does `vagrant ssh_config` output?


On Wed, Aug 1, 2012 at 5:44 PM, bmau <brya...@gmail.com> wrote:
> What do you mean by the host alias ("default")?
>
> Running vagrant ssh_config | ssh -F /dev/stdin default doesn't work for me
--
http://elhumidor.blogspot.com/
http://www.intentmedia.com/jobs

bmau

unread,
Aug 2, 2012, 1:43:23 PM8/2/12
to vagra...@googlegroups.com
Right that's basically exactly what I get.

vagrant ssh-config | ssh -F /dev/stdin default

Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.

It doesn't actually SSH in

John D. Hume

unread,
Aug 3, 2012, 7:15:34 AM8/3/12
to vagra...@googlegroups.com

It occurs to me that ssh needs stdin for you to interact with it, so I think you'll need to write ssh_config to a real file and then point the -F option at it.

-- typed with my thumbs

Reply all
Reply to author
Forward
0 new messages