views:

488

answers:

3

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

scp -r web/* [email protected]: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 [email protected]: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?

+6  A: 

Just combine the two commands:

scp -r web/* web/.htaccess [email protected]:site.com/

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

dF
+3  A: 

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.

Kyle Cronin
I'm talking about the '*' wildcard all by itself. It won't match files beginning with a dot. '.*' will match all files beginning with a dot, including the special directories '.' and '..'.
Jörg W Mittag
+3  A: 

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 ...)

Jörg W Mittag