2

I recently start to use Vagrant (and recently move to Ubuntu from Windows too). My goal to understand fundamentals of vagrant ssh.

So, I'm trying to understand what vagrant ssh actually does. I've read What does vagrant ssh actually do?, but I haven't understood anything.

I'll try to explain with an example:

  1. The first time, I connect into the vagrant machine by ssh [email protected] and typing the password.

  2. Next, I configure the keypair and connect into guest by ssh [email protected] without typing password.

  3. Next, I try to understand how vagrant implements SSH into its own guest machine:

    • In /etc/ssh/sshd_config, I set PasswordAuthentication no, but vagrant ssh still works
    • Delete insecure_private_key placed in ~/.vagrant.d on the host machine, but vagrant restores it and vagrant ssh still works.
    • Remove openssh-server in the vagrant machine and now vagrant ssh really doesn't work :)

Please could anybody in plain English explain me how vagrant implements vagrant ssh?


Update: Vagrant Docs: SSH explains actually what I need.

1 Answer 1

0

May be I didn't get the point of your question, but I'll try to explain you the main differences between vagrant ssh and ssh.

vagrant ssh is actually the same as a normal ssh, but there are several differences between them:

  • port which ssh-client tries to access;
  • private key that ssh-client uses for authentication;
  • hosts-key is switched off for vagrant so you will not get initial message "The host is unknown";
  • other minor differences.

If you know the port where vagrant runs, and know where is the private key that vagrant uses, you can use ssh instead of vagrant ssh.

4
  • Вы случаем не русский?) May me I don't understand something, but is the ssh-client should use public key instead private key? As far as I know, private key are used on the machine we connect to, hence server and public key are used on the machine we connect from, hence client. In my mind vagrant ssh must use a public key. This moment confuse me.. Commented Jan 7, 2014 at 21:42
  • The vargrant ssh wrapper uses a predefined ssh key (private). The virtual machine you are connecting to has a corresponding public key already installed in the vagrant users authorised keys file. So, when you use vagrant ssh, it doesn't require the password. It is also doing a bunch of other things as listed in this answer. The public key will be found in the ~/.ssh/authorized_keys file
    – S.Spencer
    Commented Jan 7, 2014 at 22:08
  • @TimurFayzrakhmanov: Я русский, но тогда надо идти на другой сайт, здесь за такие шуточки сразу забивают. In the both cases are used private keys, the authentication procedure is the same; the point is that vargrant uses its own keys. Commented Jan 8, 2014 at 9:04
  • Интересно!)) Thank you Igor! I've got it, the problem was poor ssh knowledge. Commented Jan 8, 2014 at 12:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.