# Remote copy through shellscript

**URL:** <https://community.unix.com/t/remote-copy-through-shellscript/346780>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [September 30, 2014, 2:43am UTC](https://community.unix.com/t/remote-copy-through-shellscript/346780 "2014-09-30T02:43:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kannansoft1985](https://community.unix.com/letter_avatar/kannansoft1985/32/5_5575768a8748004e209b776fc1b2916d.png) [@kannansoft1985](https://community.unix.com/u/kannansoft1985)\
**Post date:** [September 30, 2014, 2:43am UTC](https://community.unix.com/t/remote-copy-through-shellscript/346780/1 "2014-09-30T02:43:27Z")

</div>

I am using RedHat 4.4 Version Operating System.  
I want to copy one file from source to destination.I don't want to give a password when I am executing the below shell script.

```nohighlight
code:

#!/bin/bash
scp -r file.zip 192.168.1.5:/root/
Here it asking a password to enter,Is there any way give a password in a shell script. 

```

---

<div class="post-metadata">

**Author:** ![RavinderSingh13](https://community.unix.com/letter_avatar/ravindersingh13/32/5_5575768a8748004e209b776fc1b2916d.png) [@RavinderSingh13](https://community.unix.com/u/RavinderSingh13)\
**Post date:** [September 30, 2014, 2:54am UTC](https://community.unix.com/t/remote-copy-through-shellscript/346780/2 "2014-09-30T02:54:43Z")

</div>

> [@kannansoft1985](#):
>
> I am using RedHat 4.4 Version Operating System.  
> I want to copy one file from source to destination.I don't want to give a password when I am executing the below shell script.
> 
> ```plaintext
> code:
>  
> #!/bin/bash
> scp -r file.zip 192.168.1.5:/root/
> Here it asking a password to enter,Is there any way give a password in a shell script. 
> 
> ```

Hello kannansoft1985,

You can use `expect` script for same, in that either you can use the password(Which is not one of the best ways) or you can create a file which has password with proper permissions say `400` and call it in `expect` script. Following URL may help you.  
[Passing arguments to an Expect script as variables](http://ubuntuforums.org/showthread.php?t=503836)

Other way is to use `ssh-keygen` . You can refer following link for same.  
[https://blogs.oracle.com/jkini/entry/how\_to\_scp\_scp\_and](https://blogs.oracle.com/jkini/entry/how%5C_to%5C_scp%5C_scp_and)

Thanks,  
R. Singh

---

<div class="post-metadata">

**Author:** ![ibad\_urs](https://community.unix.com/letter_avatar/ibad_urs/32/5_5575768a8748004e209b776fc1b2916d.png) [@ibad\_urs](https://community.unix.com/u/ibad_urs)\
**Post date:** [September 30, 2014, 6:33am UTC](https://community.unix.com/t/remote-copy-through-shellscript/346780/3 "2014-09-30T06:33:45Z")

</div>

If you don't want to provide the password (i.e. don't want to do secure copy) then use below command

```nohighlight
cp /net/sourcePath<space>/destPath

```

Thanks,  
Ibadh.
