# Copy directory from chef-workstation to chef-node

**URL:** <https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543>\
**Category:** Chef Infra (archive)\
**Created:** [August 28, 2018, 7:13am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543 "2018-08-28T07:13:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepaksingla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/deepaksingla/32/2321_2.png) [@deepaksingla](https://discourse.chef.io/u/deepaksingla)\
**Post date:** [August 28, 2018, 7:13am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/1 "2018-08-28T07:13:01Z")

</div>

Hi  
I am trying to copy Directory from **chef-workstation** to **chef-node** on window environment.  
I am using below recipe

```auto
remote_directory 'C:\chef-repo\recipes\destination' do
  source 'C:\chef-repo\recipes\source'
  action :create
end

```

But It is not working.

---

<div class="post-metadata">

**Author:** ![Larryc](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Larryc](https://discourse.chef.io/u/Larryc)\
**Post date:** [August 29, 2018, 11:59am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/2 "2018-08-29T11:59:24Z")

</div>

The reason that doesn't work is because if you specify a remote file like that to like c:\ or /tmp chef thinks you are talking about the local file system on the node itself, it wont copy files from your workstation to the node like that.

What you could do it create a share on your workstation and then put the file(s) you want to access in there and reference that in your cookbook like this there are more examples in the remote\_portion of the [chef docs](https://docs.chef.io/resource_remote_file.html) search for UNC.

```
remote_file "E:/domain_test.txt" do
  source "\\\\myserver\\myshare\\mydirectory\\myfile.txt"
  remote_domain "domain"
  remote_user "username"
  remote_password "password"
end
```

---

<div class="post-metadata">

**Author:** ![deepaksingla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/deepaksingla/32/2321_2.png) [@deepaksingla](https://discourse.chef.io/u/deepaksingla)\
**Post date:** [August 31, 2018, 8:36am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/3 "2018-08-31T08:36:52Z")

</div>

Hi

Shared "ShareFolder with **x-user**.  
Now write below recipe to copy hello.txt file:

```auto
remote_file 'C:/test/hello.txt' do
  source "\\\CHEF-SERVER-Machine\\ShareFolder\\hello.txt"
  remote_domain "x-domain"
  remote_user "x-user"
  remote_password "x-password"
  action :create
end

```

Getting error:

```auto
[2018-08-31T01:31:18-07:00] ERROR: Remote chef-client error follows:
[2018-08-31T01:31:18-07:00] ERROR: Errno::EINVAL: remote_file[C:/test/hello.txt] (Remote_Directory::default line 8) had an error: Errno::EINVAL: Invalid argument @ rb_sysopen - \\CHEF-SERVER-Machine\ShareFolder\hello.txt

```

---

<div class="post-metadata">

**Author:** ![Larryc](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Larryc](https://discourse.chef.io/u/Larryc)\
**Post date:** [August 31, 2018, 11:21am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/4 "2018-08-31T11:21:27Z")

</div>

It looks like you are missing a \ before your source patch there should be 4 of them \\.

I would also check that the user account you are using can access the share.

---

<div class="post-metadata">

**Author:** ![deepaksingla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/deepaksingla/32/2321_2.png) [@deepaksingla](https://discourse.chef.io/u/deepaksingla)\
**Post date:** [August 31, 2018, 11:53am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/5 "2018-08-31T11:53:39Z")

</div>

Hi

By mistake I forgot to add one \ in the blog. But I am using 4 times .  
I am able to access share file through window url by using same domain, username and password.  
But no through chef. Facing same error.

Thanks  
Deepak

---

<div class="post-metadata">

**Author:** ![Larryc](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Larryc](https://discourse.chef.io/u/Larryc)\
**Post date:** [August 31, 2018, 12:23pm UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/6 "2018-08-31T12:23:36Z")

</div>

Oh ok I just wanted to make sure you had all 4.

Are you on a active directory domain? You also may need to make a change to your workstation firewall to allow the connections you would need to allow connections over port 445.

---

<div class="post-metadata">

**Author:** ![deepaksingla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/deepaksingla/32/2321_2.png) [@deepaksingla](https://discourse.chef.io/u/deepaksingla)\
**Post date:** [August 31, 2018, 12:59pm UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/7 "2018-08-31T12:59:25Z")

</div>

Hi

I turn off the Firewall of chef-workstation, still same error. **Invalid Argument**

```auto
[2018-08-31T05:57:39-07:00] ERROR: Remote chef-client error follows:
[2018-08-31T05:57:39-07:00] ERROR: Errno::EINVAL: remote_file[C:/chef/hello.txt] (Remote_Directory::default line 8) had an error: Errno::EINVAL: Invalid argument @ rb_sysopen - \\CHEF-SERVER-Machine\ShareFolder\hello.txt

```

---

<div class="post-metadata">

**Author:** ![Larryc](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Larryc](https://discourse.chef.io/u/Larryc)\
**Post date:** [August 31, 2018, 1:49pm UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/8 "2018-08-31T13:49:56Z")

</div>

Is your chef workstation the same as chef-server-machine?

---

<div class="post-metadata">

**Author:** ![deepaksingla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/deepaksingla/32/2321_2.png) [@deepaksingla](https://discourse.chef.io/u/deepaksingla)\
**Post date:** [August 31, 2018, 1:51pm UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/9 "2018-08-31T13:51:17Z")

</div>

yes

---

<div class="post-metadata">

**Author:** ![deepaksingla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/deepaksingla/32/2321_2.png) [@deepaksingla](https://discourse.chef.io/u/deepaksingla)\
**Post date:** [August 31, 2018, 1:55pm UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/10 "2018-08-31T13:55:12Z")

</div>

Just to inform you, I am directly communicating between chef-workstation and chef-node.  
I have no chef-server.

---

<div class="post-metadata">

**Author:** ![Larryc](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Larryc](https://discourse.chef.io/u/Larryc)\
**Post date:** [August 31, 2018, 4:28pm UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/11 "2018-08-31T16:28:14Z")

</div>

I got a windows vagrant box and tried this out.

I created a local share and gave my user account implicit full access to the share

under sharing I clicked advanced sharing checked the box, gave the share a name of share$, then I clicked permissions, added my user account and gave it full access. then clicked ok.

I then made a quick cookbook with a recipe as follows.

directory 'c:/test' do  
action :create  
end

remote\_file 'c:/test/test.txt' do  
source '\\[laptop.company.com](http://laptop.company.com)\share$\test.txt'  
remote\_domain '[company.com](http://company.com)'  
remote\_user 'larryc'  
remote\_password 'Hunter2'  
action :create  
end

and it worked as expected

Recipe: filecopy::default  
\* directory[c:/test] action create (up to date)  
\* remote\_file[c:/test/test.txt] action create  
- create new file c:/test/test.txt  
- update content in file c:/test/test.txt from none to e3b0c4  
(no diff)

You might want to check that your share has the proper permissions.

---

<div class="post-metadata">

**Author:** ![deepaksingla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/deepaksingla/32/2321_2.png) [@deepaksingla](https://discourse.chef.io/u/deepaksingla)\
**Post date:** [September 2, 2018, 5:10am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/12 "2018-09-02T05:10:50Z")

</div>

Thanks Larryc

I got the mistake. I was not using domain in the **source** path.  
Below script is working file.

```auto
remote_file 'C:/test/hello.txt' do
  source "\\\CHEF-SERVER-Machine.x-domain\\ShareFolder\\hello.txt"
  remote_domain "x-domain"
  remote_user "x-user"
  remote_password "x-password"
  action :create
end

```

---

<div class="post-metadata">

**Author:** ![Larryc](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Larryc](https://discourse.chef.io/u/Larryc)\
**Post date:** [September 2, 2018, 11:33am UTC](https://discourse.chef.io/t/copy-directory-from-chef-workstation-to-chef-node/13543/13 "2018-09-02T11:33:45Z")

</div>

Cool glad I could be of help.
