如何使用“scp”部署网站的“.htaccess”文件?
我当前正在使用以下命令上传我的网站内容:
scp -r web/* [email protected]:site.com/
除了不发送 .htaccess 文件之外,这效果很好。 据推测,这是因为它被隐藏了。
我尝试添加第二行来明确发送文件:
scp -r web/.htaccess [email protected]:site.com/.htaccess
这非常有效,只是现在我必须输入密码两次。
关于如何仅使用 1 或 0 条密码进行此部署,您有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一些背景信息:
*
通配符与所谓的“点文件”(即名称以点开头的文件)不匹配。有些 shell 允许您设置一个选项,以便它将匹配点文件,但是,这样做会带来很大的痛苦:现在
*
也将匹配 < code>. (当前目录)和..
(父目录),这通常不是预期的结果,而且可能会令人非常惊讶! (rm -rf *
删除父目录可能不是开始新的一天的最佳方式......)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 ...)只需组合这两个命令即可:
如果您想要 0 次密码输入,您可以设置 公钥身份验证< /a> 用于 ssh/scp。
Just combine the two commands:
If you want 0 entries of your password you can set up public key authentication for ssh/scp.
警告 - 不要尝试将点文件(如
.htaccess
)与.*
匹配 - 这也会不方便地匹配..
,并将导致将路径上的所有文件复制到根目录。 我曾经这样做过一次(使用rm
,不少!),并且我不得不重建服务器,因为我弄乱了/var
。@jwmittag:
我刚刚在 Ubuntu 上进行了测试,当我使用 cp 时,
.*
匹配。 下面是一个示例:如果
.*
与..
不匹配,则d
不应位于b
中。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 (withrm
, 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 usecp
. Here's an example:If
.*
did not match..
, thend
shouldn't be inb
.