Google compute error: ssh_username must be specified

331 views
Skip to first unread message

Andy Spooner

unread,
Jan 3, 2017, 7:02:49 PM1/3/17
to Packer

I am testing creating images on Google Cloud Compute using Packer. However, when i run a  build demo using the packer.json file below I receive the following error:

An ssh_username must be specified

  Note: some builders used to default ssh_username to "root".


Packer's documentation states that I may need to add a ssh_username to the Google Cloud builder. However, Google usernames are in the format of an email address; when i set ssh_username to a valid email address that has been authenticated to Google Cloud, Packer reports this as an error of incorrect format.

Can someone please point me in the direction where i can find appropriate documentation to setup ssh_username correctly and to promote to sudo?

Note, I have tried authenticating with a service key without joy. Using a service key is my preferred option.





packer.json 

{

  "variables": {

    "git_commit": "",

    "git_branch": "",

    "account_file": "test/test-******.json",

    "project_id": "test-11211"

  },

  "builders": [

    {

      "type": "googlecompute",

      "account_file": "{{user `account_file`}}",

      "project_id": "{{user `project_id`}}",

      "source_image": "ubuntu-1404-trusty-v20161213",

      "zone": "us-central1-a",

      "image_name": "redmine-{{timestamp}}-{{user `git_branch`}}-{{user `git_commit`}}"

    }

  ],

  "provisioners": [

    {

      "type": "chef-solo",

      "install_command": "apt-get update && apt-get install -y curl && curl -L https://www.opscode.com/chef/install.sh | {{if .Sudo}}sudo{{end}} bash",

      "cookbook_paths": ["chef/site-cookbooks"],

      "run_list": [

        "recipe[rails-sample]",

        "recipe[rails-sample::user]",

        "recipe[rails-sample::ruby]",

        "recipe[rails-sample::app]"

      ]

    }

  ]

}




Cheers

And

Alvaro Miranda Aguilera

unread,
Jan 4, 2017, 2:51:00 AM1/4/17
to packe...@googlegroups.com
Hello.

ssh_username  is the user to be used in the VM/Instance to log in.

IT should default to root, which here seems is not.

Can you set it up to root and test?

Whatever the result, could you please create an Issue on github to track this?


  "builders": [

    {

      "type": "googlecompute",

      "account_file": "{{user `account_file`}}",

      "project_id": "{{user `project_id`}}",

      "source_image": "ubuntu-1404-trusty-v20161213",

      "zone": "us-central1-a",

      "image_name": "redmine-{{timestamp}}-{{user `git_branch`}}-{{user `git_commit`}}",

      "ssh_username": "root"

    }




--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/82b7ee9e-c56c-4a76-afbf-08dc109f1c17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Rickard von Essen

unread,
Jan 4, 2017, 3:29:04 AM1/4/17
to packe...@googlegroups.com
ssh_username doesn't have a default value anymore. It must be specified. Ubuntu doesn't allow ssh with root. Since this image has GCE tools it will create the user you give and give it sudo rights. So just add ssh_username: ubuntu should work. 

Andy Spooner

unread,
Jan 4, 2017, 5:23:41 PM1/4/17
to Packer
Thank you for the advice. I was able to build an image by adding  "ssh_username": "root". The user 'root' can be substituted with any another name, as the user will be created as part of the build.


Best
Reply all
Reply to author
Forward
0 new messages