VM refuses key on Windows

7,372

Solution 1

Try using this public key instead:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAsD+KWzLA96mAM9hkwy/xWdRT6+aUJ72M2ZyrZMk/GZTGfZxPXKgNvhPB/2AF3tVikcp8XNw5iVN/Lfu6+9JCzeDl3E4r9Xcbx0zCeclOY8ofLCD1rsKRCC/E33aew/y4QMkGfZQeXj3mVsuQxuPrr5tCTziKUKz7QTNn/MLINa1YuqsO5aqO1ujCeT2RjwShXVcvjFzT9/fRXiaH0M1hygcuIYY3T8MOp6dGPoBHB6WOuVgv5X+BTsilRuL+mQTWnZZw93NF2ySgEZFHwPoMLBCCc+A1quZV+aoDBTaVsOdsSGeCWMAW5oytsG7M/ATUDmZOI7D+M9UWIXkdvImusQ==

and add this to the authorized_keys file.

There is an issue with the format of Putty-generated keys when used with SSH, it might easily be the cause of that error message you are seeing.

Update With regards to how to configure all this on Windows, have a look at this question on stackoverflow, maybe it will point you in the right direction.

Update 2 Try saving the public key as insecure_public_key.ppk (see this article)

Solution 2

For security purposes I've set PuPHPet to disable the built-in SSH key and generate a unique key for each VM you up.

However, I should probably add a putty-compatible version, too!

Share:
7,372

Related videos on Youtube

Andresch Serj
Author by

Andresch Serj

Senior PHP Developer that also likes AngularJS, jQuery, node.js and Bicycles (Road Bikes, Tall Bikes, Cyclo Cross, Old Rusty Bikes, Fixed Gear), Strava, Spraynard, Circle Takes the Square and Cats.

Updated on September 18, 2022

Comments

  • Andresch Serj
    Andresch Serj over 1 year

    My Vagrant VM is up and running, but if i check netstat, it is just ESTABLISHED but not LISTENING.

      TCP    192.168.56.1:139       0.0.0.0:0              LISTENING
      TCP    192.168.56.1:50973     192.168.56.101:22      ESTABLISHED
    

    Thouz as i found out, this apparently is not an issue, I can not connect to it using putty because it refuses my key.

    login as: vagrant
    Server refused our key
    [email protected]'s password:
    

    I am using a private key without passphrase that is stored locally and known to putty. I configured vagrant to use it in the config.yaml

    ssh:
        host: null
        port: null
        private_key_path: ./puphpet/files/dot/ssh/vagrant_key
    

    In the vagrant_key Folder i have the public key as vagrant and vagrant.pub and the private key as vagrant.ppk

    Anyone any Ideas or Hints?


    EDIT: i adjusted my Public SSH File (vagrant.pub) from Puttygen which now looks like:

    ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAsD+KWzLA96mAM9hkwy/xWdRT6+aUJ72M2ZyrZMk/GZTGfZxPXKgNvhPB/2AF3tVikcp8XNw5iVN/Lfu6+9JCzeDl3E4r9Xcbx0zCeclOY8ofLCD1rsKRCC/E33aew/y4QMkGfZQeXj3mVsuQxuPrr5tCTziKUKz7QTNn/MLINa1YuqsO5aqO1ujCeT2RjwShXVcvjFzT9/fRXiaH0M1hygcuIYY3T8MOp6dGPoBHB6WOuVgv5X+BTsilRuL+mQTWnZZw93NF2ySgEZFHwPoMLBCCc+A1quZV+aoDBTaVsOdsSGeCWMAW5oytsG7M/ATUDmZOI7D+M9UWIXkdvImusQ== rsa-key-20140423
    

    It still doesn't work.


    EDIT: While i couldn't fix my Putty Problem (yet), thanks to @user1301428 i found a way to connect to my VM using vagrant ssh, which can be used under windows if you have the ssh.exe from git in your PATH Variable. Read this Stackoverflow article here for help.

    • user1301428
      user1301428 about 10 years
      It's not that you can't connect to it via SSH because the connection is established, that simply means that the connection has been successful. The problem is another one. 1) How did you generate the key pair? 2) Can you post the contents of /var/log/auth.log? 3) I am not extremely familiar with Vagrant, but in config.yaml, shouldn't private_key_path be something like ./puphpet/files/dot/ssh/vagrant_key/vagrant.ppk, i.e. including the name of the key?
    • Andresch Serj
      Andresch Serj about 10 years
      @user1301428 1) I generated teh key pair using puttygen. 2) Where do i find the auth.log on my Windows machine? 3) the private_key_path actually has to be set like this.
    • user1301428
      user1301428 about 10 years
      Can you paste the contents of the public key? I think I know what the problem is but I just want to make sure.
    • Andresch Serj
      Andresch Serj about 10 years
      @user1301428 I did. You think that might be the problem?
    • user1301428
      user1301428 about 10 years
      Yep, see my answer below :)
    • JustAMartin
      JustAMartin about 8 years
      I had the same issue, I finally gave up and tried to enter vagrant as password and it worked.
  • Andresch Serj
    Andresch Serj about 10 years
    How do i add it to the authorized_keys file on windows?
  • user1301428
    user1301428 about 10 years
    @AndreschSerj Again, I am not very familiar with vagrant, but can you try vagrant ssh and update the file now through this? After you have solved the ssh issues you can start using Putty.
  • Andresch Serj
    Andresch Serj about 10 years
    i appreciate your effort, but that did not solve the issue, nor can i use vagrant ssh since windows has no ssh command line tool :-( I agree on your public key solution thou so +1 :D
  • Andresch Serj
    Andresch Serj about 10 years
    I know that Article. Didn't help :(
  • user1301428
    user1301428 about 10 years
    @AndreschSerj have you also checked the section about patching ssh code? That should enable you to use vagrant ssh on Windows. Also, answer updated.
  • user1301428
    user1301428 about 10 years
    @AndreschSerj Also, after updating the public key, try deleting and recreating the VM, it might also be some weird-i-don't-know-what-kind-of-caching-problem.
  • Andresch Serj
    Andresch Serj about 10 years
    Adding the path to git's ssh.exe worked! Now i can access my machine via vagrant ssh! How did i overread that? Thanks a lot thou! Sadly it doesn't solve the putty problem but it solves my problem.
  • user1301428
    user1301428 about 10 years
    @AndreschSerj great that it worked! At least now you can try solving the Putty problem because you have access to the machine and you can update the authorized_keys file :)