Rsync Synced Folder does not work when `requiretty' is enabled
Even if I set config.ssh.pty = true (#1482), the rsync function does not properly work.
==> default: Rsyncing folder: /home/****/****/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /home/****/****/
Guest path: /vagrant
Command: rsync --verbose --archive --delete -z --copy-links --no-owner --no-group --rsync-path sudo rsync -e ssh -p 22 -o StrictHostKeyChecking=no -o IdentitiesOnly=true -o UserKnownHostsFile=/dev/null -i '/home/****/****/****.pem' --exclude .vagrant/ /home/****/****/ ec2-user@**.**.**.**:/vagrant
Error: Warning: Permanently added '**.**.**.**' (ECDSA) to the list of known hosts.
sudo: sorry, you must have a tty to run sudo
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
Command "vagrant up --provider=aws" exited with 1
The reason is --rync-path sudo rsync.
In the guest environment sudo cannot be invoked without tty.
If the options for opening shell session (rsync -e ...) can be configured properly (e.g., ssh -tt) the problem is supposed to be resolved, but those options are fixed and cannot be modified.
(cf. https://github.com/mitchellh/vagrant/blob/master/plugins/synced_folders/rsync/helper.rb#L74)
Does anyone know workaround for this problem?
Hi @kissge
I am sorry you are having issues with Vagrant. Can you please share your Vagrantfile, host OS, guest OS, and the output of the command in debug mode as as github gist? Thanks! :smile:
I'm having the same issue, specifically with the Amazon Linux AMI 2015.09.1 image.
Host: OS X 10.11.2 Vagrant: 1.8.1 vagrant-aws (0.7.0) vagrant-berkshelf (4.1.0) vagrant-hostmanager (1.7.0) vagrant-omnibus (1.4.1) vagrant-reload (0.0.1) vagrant-share (1.1.5, system) vagrant-vbguest (0.11.0)
Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.vm.provider :aws do |aws, override|
aws.access_key_id = "***"
aws.secret_access_key = "***"
aws.keypair_name = "foo"
aws.ami = "ami-60b6c60a" # Amazon Linux AMI 2015.09.1
override.ssh.pty = true
override.ssh.username = "ec2-user"
override.ssh.private_key_path = "~/.ssh/foo.pem"
end
end
Output:
==> default: Rsyncing folder: /Users/apancutt/workspace/vagrant/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /Users/apancutt/workspace/vagrant/
Guest path: /vagrant
Command: rsync --verbose --archive --delete -z --copy-links --no-owner --no-group --rsync-path sudo rsync -e ssh -p 22 -o ControlMaster=auto -o ControlPath=/var/folders/f6/63j1_6111vv6cfnvd5gxbhww0000gn/T/ssh.331 -o ControlPersist=10m -o StrictHostKeyChecking=no -o IdentitiesOnly=true -o UserKnownHostsFile=/dev/null -i '/Users/apancutt/.ssh/foo.pem' --exclude .vagrant/ /Users/apancutt/workspace/vagrant/ ec2-user@***:/vagrant
Error: Warning: Permanently added '***' (ECDSA) to the list of known hosts.
sudo: sorry, you must have a tty to run sudo
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]
:+1: I'm getting this same issue Standard Ubuntu 14.04 image from aws launching from OS X 10.11.3
==> default: Rsyncing folder: /Users/Documents/CodeRepos/chef-configure/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /Users/Documents/CodeRepos/chef-configure/
Guest path: /vagrant
Command: rsync --verbose --archive --delete -z --copy-links --no-owner --no-group --rsync-path sudo rsync -e ssh -p 22 -o StrictHostKeyChecking=no -o IdentitiesOnly=true -o UserKnownHostsFile=/dev/null -i '/keys/dev.pem' --exclude .vagrant/ /Users/Documents/CodeRepos/chef-configure/ [email protected]:/vagrant
Error: Warning: Permanently added '192.168.1.69' (ECDSA) to the list of known hosts.
packet_write_wait: Connection to 192.168.1.69: Broken pipe
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]
hey folks, one option is to disable the requirement for a tty.
You need something like the following in your instance userdata
#!/bin/bash
echo 'Defaults:root !requiretty' > /etc/sudoers.d/aws
echo 'Defaults:vagrant !requiretty' >> /etc/sudoers.d/aws
Yes, it is an option. But as far as I tested it does not always work well. It seemed that it is unpredictable whether the script runs before or after vagrant tries to connect the server via ssh. If it runs before vagrant, then it works; otherwise it fails.
And besides, that solution only works with Amazon EC2 instances. After all improving vagrant seems a better solution to me.
I'm not familiar with Ruby, but it seems like if the code that built the rsync rsh command were updated to respect config.ssh.pty, that should fix things nicely.
We did some refactors. Can anyone confirm if this is still an issue with Vagrant 1.8.4?
I am hitting this issue with Vagrant 1.8.4.
+1 same issue here with Vagrant 1.8.5 and vagrant-aws (0.7.2).
I have the same problem with vagrant 1.8.5 and vagrant-aws (0.7.2) like @ayen-tibco
Same here when using custom AMI.
I think it worked with:
config.ssh.pty = true
added into Vagrantfile.
If you've got Broken pipe instead, see this.
Hi there,
Thanks for reporting this bug. I'm sure this was a real issue when originally reported (our fault for not looking sooner!) but there have been multiple Vagrant releases since the original report. I'm going to close this issue now and request you reopen the issue if you're still experiencing this problem. I'm sorry this wasn't looked at earlier :frowning_face:
Cheers!
When I did vagrant up with the box centos/7 (virtualbox, 1703.01), ==> default: Rsyncing folder: /root/ => /vagrant was stuck for me too, and adding
config.vm.synced_folder '.', '/vagrant', disabled: true
in Vagrantfile resolved the issue for me and rsync did not happen.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.