-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: "no implicit conversion of nil into String (TypeError)" #78
Comments
Here is a patch based on master: https://pastebin.com/dEWp6JTu The issue is that the code doesn't take into account that a lot of people have their keys in an agent. It tries to add an IdentityFile option against a value that doesn't exist. The patch checks if a private key has been specified and adds the option. |
copying patch here in case paste goes away: diff --git a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
index 4dc4a16..9068919 100644
--- a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
+++ b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
@@ -210,7 +210,11 @@ module VagrantPlugins
ssh_opts = opts[:ssh_opts]
ssh_opts+= ' -o User=' + machine.ssh_info[:username]
ssh_opts+= ' -o Port=' + machine.ssh_info[:port].to_s
- ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
+ if machine.ssh_info.key?(:private_key_path) and
+ machine.ssh_info[:private_key_path] and
+ machine.ssh_info[:private_key_path][0]
+ ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
+ end
ssh_opts+= ' -o UserKnownHostsFile=/dev/null '
ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config |
@arcege - can you describe in detail how you would reproduce? just use agent instead of having vagrant generate pub/priv keypair? |
Yes, so not including some of the specifics, the Vagrantfile looks like: Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.vm.box_check_update = false
config.ssh.username = "ubuntu"
config.ssh.keys_only = false
#config.ssh.private_key_path = "myPrivateKeyFile"
config.vm.provider :aws do |aws|
aws.ami = $USEAMI # ubuntu/xenial64
aws.instance_type = "m4.xlarge"
aws.keypair_name = $MYEC2KEY
aws.security_groups = $SECGRPS
aws.subnet_id = $SUBNET
aws.associate_public_ip = true
aws.tags = $TAGS
end
# we don't want to sync against /vagrant, especially if we have large repos
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder workspace + "/", "/home/ubuntu/remote", type: "sshfs"
end Fails with the nil+String error without the patch, succeeds with the patch. Without the patch, uncomment the private_key_path line for success. Comment out the sshfs line and success with or without the patch. |
Same issue with reverse mounts. Against 1.3.0 and ad92b8b (refs/heads/master). Updated patch is: diff --git a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
index 4dc4a16..9068919 100644
--- a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
+++ b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
@@ -210,7 +210,11 @@ module VagrantPlugins
ssh_opts = opts[:ssh_opts]
ssh_opts+= ' -o User=' + machine.ssh_info[:username]
ssh_opts+= ' -o Port=' + machine.ssh_info[:port].to_s
- ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
+ if machine.ssh_info.key?(:private_key_path) and
+ machine.ssh_info[:private_key_path] and
+ machine.ssh_info[:private_key_path][0]
+ ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
+ end
ssh_opts+= ' -o UserKnownHostsFile=/dev/null '
ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config
diff --git a/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb b/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb
index 8fdaefa..c011cc4 100644
--- a/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb
+++ b/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb
@@ -70,7 +70,11 @@ module VagrantPlugins
# Note the backslash escapes for IdentityFile - handles spaces in key path
ssh_opts = opts[:ssh_opts]
ssh_opts+= ' -o Port=' + machine.ssh_info[:port].to_s
- ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
+ if machine.ssh_info.key?(:private_key_path) and
+ machine.ssh_info[:private_key_path] and
+ machine.ssh_info[:private_key_path][0]
+ ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
+ end
ssh_opts+= ' -o UserKnownHostsFile=/dev/null '
ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config |
In some cases there may be no IdentityFile you are using to ssh into the guest (one example is using AWS provider and the remote AMI already has the user's SSH key embedded in it by the cloud provider). Handle this case. Thanks to Michael P Reilly (https://github.com/arcege) for providing this patch in the issue (#78). Fixes #78.
Windows 10 Home host, boot2docker guest. When i try to add folder with:
i get this error
The text was updated successfully, but these errors were encountered: