{"action":"opened","issue":{"url":"https://api.github.com/repos/mitchellh/vagrant/issues/7518","repository_url":"https://api.github.com/repos/mitchellh/vagrant","labels_url":"https://api.github.com/repos/mitchellh/vagrant/issues/7518/labels{/name}","comments_url":"https://api.github.com/repos/mitchellh/vagrant/issues/7518/comments","events_url":"https://api.github.com/repos/mitchellh/vagrant/issues/7518/events","html_url":"https://github.com/mitchellh/vagrant/issues/7518","id":162028944,"number":7518,"title":"Generated authorized_keys missing newline at end of line/file","user":{"login":"derks","id":130503,"avatar_url":"https://avatars.githubusercontent.com/u/130503?v=3","gravatar_id":"","url":"https://api.github.com/users/derks","html_url":"https://github.com/derks","followers_url":"https://api.github.com/users/derks/followers","following_url":"https://api.github.com/users/derks/following{/other_user}","gists_url":"https://api.github.com/users/derks/gists{/gist_id}","starred_url":"https://api.github.com/users/derks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derks/subscriptions","organizations_url":"https://api.github.com/users/derks/orgs","repos_url":"https://api.github.com/users/derks/repos","events_url":"https://api.github.com/users/derks/events{/privacy}","received_events_url":"https://api.github.com/users/derks/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-23T21:35:38Z","updated_at":"2016-06-23T21:35:38Z","closed_at":null,"body":"### System\r\n\r\n * Vagrant: `1.8.4`\r\n * Host OS: `OSX 10.11.5`\r\n * Guest Operating System: `Ubuntu 14.04 LTS`\r\n\r\n### Vagrantfile\r\n\r\n```ruby\r\n# -*- mode: ruby -*-\r\n# vi: set ft=ruby :\r\n\r\nVagrant.configure(\"2\") do |config|\r\n  config.vm.box = \"https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box\"\r\nend\r\n```\r\n\r\n### Expected behavior\r\n\r\nThe generated `~/.ssh/authorized_keys` file (or the public key line) should end with a `\\n` (new line).\r\n\r\n```\r\nvagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.ssh/authorized_keys\r\n# CLOUD_IMG: This file was created/modified by the Cloud Image build process\r\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFyVE94t4N+DKktZIFBoTw9CJFsLh4oCgVd0nOX5d4vmW6f4iOJuOkscWdbjyqOY+Glzaa/K77YJTGQZMy4V1FNrxfx7hmMPiiAio7q43MQ3h4pkc6rjkFJ7eYepn14HLcLfOBxU+dmsdocE27KA9V+CI3MhRu8zry9UaNZMuilh2YhpyQea2Zryj9E1w+29zrvJiGYw6yQe9O9scaO+W/C5MXXyNgiENUIappCTa6/Kl6oBx6dxsN36pYERbzlzM+zhA+ArrlxhJSlgc9OFRKbJsTaiAyU8RkvSV3TuKTgegTdCjEPUAbvkonRD91BUo23OdbikZ1XjJooYjF6Hpl vagrant\r\nvagrant@vagrant-ubuntu-trusty-64:~$\r\n\r\nvagrant@vagrant-ubuntu-trusty-64:~$ echo \"THIS WOULD BE ANOTHER KEY\" >> ~/.ssh/authorized_keys\r\n\r\nvagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.ssh/authorized_keys\r\n# CLOUD_IMG: This file was created/modified by the Cloud Image build process\r\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFyVE94t4N+DKktZIFBoTw9CJFsLh4oCgVd0nOX5d4vmW6f4iOJuOkscWdbjyqOY+Glzaa/K77YJTGQZMy4V1FNrxfx7hmMPiiAio7q43MQ3h4pkc6rjkFJ7eYepn14HLcLfOBxU+dmsdocE27KA9V+CI3MhRu8zry9UaNZMuilh2YhpyQea2Zryj9E1w+29zrvJiGYw6yQe9O9scaO+W/C5MXXyNgiENUIappCTa6/Kl6oBx6dxsN36pYERbzlzM+zhA+ArrlxhJSlgc9OFRKbJsTaiAyU8RkvSV3TuKTgegTdCjEPUAbvkonRD91BUo23OdbikZ1XjJooYjF6Hpl vagrant\r\nTHIS WOULD BE ANOTHER KEY\r\nvagrant@vagrant-ubuntu-trusty-64:~$\r\n```\r\n\r\n### Actual behavior\r\n\r\nThe generated `~/.ssh/authorized_keys` file does not end with a `\\n` (new line).  This causes issues when trying to **append** additional keys to the file.\r\n\r\n```\r\nvagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.ssh/authorized_keys\r\n# CLOUD_IMG: This file was created/modified by the Cloud Image build process\r\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFyVE94t4N+DKktZIFBoTw9CJFsLh4oCgVd0nOX5d4vmW6f4iOJuOkscWdbjyqOY+Glzaa/K77YJTGQZMy4V1FNrxfx7hmMPiiAio7q43MQ3h4pkc6rjkFJ7eYepn14HLcLfOBxU+dmsdocE27KA9V+CI3MhRu8zry9UaNZMuilh2YhpyQea2Zryj9E1w+29zrvJiGYw6yQe9O9scaO+W/C5MXXyNgiENUIappCTa6/Kl6oBx6dxsN36pYERbzlzM+zhA+ArrlxhJSlgc9OFRKbJsTaiAyU8RkvSV3TuKTgegTdCjEPUAbvkonRD91BUo23OdbikZ1XjJooYjF6Hpl vagrantvagrant@vagrant-ubuntu-trusty-64:~$\r\n\r\nvagrant@vagrant-ubuntu-trusty-64:~$ echo \"THIS WOULD BE ANOTHER KEY\" >> ~/.ssh/authorized_keys\r\n\r\nvagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.ssh/authorized_keys\r\n# CLOUD_IMG: This file was created/modified by the Cloud Image build process\r\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFyVE94t4N+DKktZIFBoTw9CJFsLh4oCgVd0nOX5d4vmW6f4iOJuOkscWdbjyqOY+Glzaa/K77YJTGQZMy4V1FNrxfx7hmMPiiAio7q43MQ3h4pkc6rjkFJ7eYepn14HLcLfOBxU+dmsdocE27KA9V+CI3MhRu8zry9UaNZMuilh2YhpyQea2Zryj9E1w+29zrvJiGYw6yQe9O9scaO+W/C5MXXyNgiENUIappCTa6/Kl6oBx6dxsN36pYERbzlzM+zhA+ArrlxhJSlgc9OFRKbJsTaiAyU8RkvSV3TuKTgegTdCjEPUAbvkonRD91BUo23OdbikZ1XjJooYjF6Hpl vagrantTHIS WOULD BE ANOTHER KEYvagrant@vagrant-ubuntu-trusty-64:~$\r\n```\r\n\r\n### Steps to reproduce\r\n\r\n1. `vagrant init https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box`\r\n2. `vagrant up`\r\n3. `vagrant ssh`\r\n4. `cat ~/.ssh/authorized_keys`\r\n\r\n\r\nNote that this is **not** only relevant to the Ubuntu 14.04 image used in this example, I've verified the issue with other boxes as well.\r\n\r\n\r\n### Full Example Output\r\n\r\n```\r\nderks@macbook vagrant-test $ vagrant up\r\nBringing machine 'default' up with 'virtualbox' provider...\r\n==> default: Box 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box' could not be found. Attempting to find and install...\r\n    default: Box Provider: virtualbox\r\n    default: Box Version: >= 0\r\n==> default: Box file was not detected as metadata. Adding it directly...\r\n==> default: Adding box 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box' (v0) for provider: virtualbox\r\n    default: Downloading: https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box\r\n==> default: Successfully added box 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box' (v0) for 'virtualbox'!\r\n==> default: Importing base box 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box'...\r\n==> default: Matching MAC address for NAT networking...\r\n==> default: Setting the name of the VM: vagrant-test_default_1466716360635_54571\r\n==> default: Clearing any previously set forwarded ports...\r\n==> default: Fixed port collision for 22 => 2222. Now on port 2203.\r\n==> default: Clearing any previously set network interfaces...\r\n==> default: Preparing network interfaces based on configuration...\r\n    default: Adapter 1: nat\r\n==> default: Forwarding ports...\r\n    default: 22 (guest) => 2203 (host) (adapter 1)\r\n==> default: Booting VM...\r\n==> default: Waiting for machine to boot. This may take a few minutes...\r\n    default: SSH address: 127.0.0.1:2203\r\n    default: SSH username: vagrant\r\n    default: SSH auth method: private key\r\n    default:\r\n    default: Vagrant insecure key detected. Vagrant will automatically replace\r\n    default: this with a newly generated keypair for better security.\r\n    default:\r\n    default: Inserting generated public key within guest...\r\n    default: Removing insecure key from the guest if it's present...\r\n    default: Key inserted! Disconnecting and reconnecting using new SSH key...\r\n==> default: Machine booted and ready!\r\n==> default: Checking for guest additions in VM...\r\n==> default: Mounting shared folders...\r\n    default: /vagrant => /Users/derks/Development/vagrant-test\r\n\r\nderks@macbook vagrant-test $ vagrant ssh\r\n\r\nvagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.ssh/authorized_keys\r\n# CLOUD_IMG: This file was created/modified by the Cloud Image build process\r\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFyVE94t4N+DKktZIFBoTw9CJFsLh4oCgVd0nOX5d4vmW6f4iOJuOkscWdbjyqOY+Glzaa/K77YJTGQZMy4V1FNrxfx7hmMPiiAio7q43MQ3h4pkc6rjkFJ7eYepn14HLcLfOBxU+dmsdocE27KA9V+CI3MhRu8zry9UaNZMuilh2YhpyQea2Zryj9E1w+29zrvJiGYw6yQe9O9scaO+W/C5MXXyNgiENUIappCTa6/Kl6oBx6dxsN36pYERbzlzM+zhA+ArrlxhJSlgc9OFRKbJsTaiAyU8RkvSV3TuKTgegTdCjEPUAbvkonRD91BUo23OdbikZ1XjJooYjF6Hpl vagrantvagrant@vagrant-ubuntu-trusty-64:~$\r\n\r\nvagrant@vagrant-ubuntu-trusty-64:~$ echo \"THIS WOULD BE ANOTHER KEY\" >> ~/.ssh/authorized_keys\r\n\r\nvagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.ssh/authorized_keys\r\n# CLOUD_IMG: This file was created/modified by the Cloud Image build process\r\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFyVE94t4N+DKktZIFBoTw9CJFsLh4oCgVd0nOX5d4vmW6f4iOJuOkscWdbjyqOY+Glzaa/K77YJTGQZMy4V1FNrxfx7hmMPiiAio7q43MQ3h4pkc6rjkFJ7eYepn14HLcLfOBxU+dmsdocE27KA9V+CI3MhRu8zry9UaNZMuilh2YhpyQea2Zryj9E1w+29zrvJiGYw6yQe9O9scaO+W/C5MXXyNgiENUIappCTa6/Kl6oBx6dxsN36pYERbzlzM+zhA+ArrlxhJSlgc9OFRKbJsTaiAyU8RkvSV3TuKTgegTdCjEPUAbvkonRD91BUo23OdbikZ1XjJooYjF6Hpl vagrantTHIS WOULD BE ANOTHER KEY\r\nvagrant@vagrant-ubuntu-trusty-64:~$\r\n```"}}
{"actor":{"display_login":"derks"}}