4

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?

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Frank Krueger
  • 69,552
  • 46
  • 163
  • 208

3 Answers3

9

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.

dF.
  • 74,139
  • 30
  • 130
  • 136
4

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
  • 363,080
  • 75
  • 446
  • 653
3

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.

mtb
  • 1,350
  • 16
  • 32
Kyle Cronin
  • 77,653
  • 43
  • 148
  • 164
  • 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 Sep 21 '08 at 04:14