Question

I am currently using the following command to upload my site content:

scp -r web/* user@site.com:site.com/

This works great except that the .htaccess file is not sent. Presumably, this is because it's hidden.

I have tried adding a second line to send the file explicitely:

scp -r web/.htaccess user@site.com:site.com/.htaccess

This works great except now I have to enter my password twice.

Any thoughts on how to make this deploy with only 1 or 0 entries of my password?

Was it helpful?

Solution

Just combine the two commands:

scp -r web/* web/.htaccess user@site.com:site.com/

If you want 0 entries of your password you can set up public key authentication for ssh/scp.

OTHER TIPS

Some background info: the * wildcard does not match so-called "dot-files" (i.e. files whose name begins with a dot).

Some shells allow you to set an option, so that it will match dot-files, however, doing that is asking for a lot of pain: now * will also match . (the current directory) and .. (the parent directory), which is usually not what is intended and can be quite surprising! (rm -rf * deleting the parent directory is probably not the best way to start a day ...)

A word of caution - don't attempt to match dotted files (like .htaccess) with .* - this inconveniently also matches .., and would result in copying all the files on the path to the root directory. I did this once (with rm, no less!) and I had to rebuild the server because I'd messed with /var.

@jwmittag:

I just did a test on Ubuntu and .* matches when I use cp. Here's an example:

root@krash:/# mkdir a
root@krash:/# mkdir b
root@krash:/# mkdir a/c
root@krash:/# touch a/d
root@krash:/# touch a/c/e
root@krash:/# cp -r a/c/.* b
cp: will not create hard link `b/c' to directory `b/.'
root@krash:/# ls b
d  e

If .* did not match .., then d shouldn't be in b.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top