.PEM 的存储位置,无人可以访问,但可以在 PHP 中访问

发布于 2024-12-17 21:04:41 字数 270 浏览 5 评论 0原文

http://www.stellarwebsolutions.com/en/articles.php

我刚刚得到了.pem 与 paypal 一起使用,但我无法找到一种方法来访问 .pem,而不将其放在我的 public_html/ 文件夹中,我知道这可能不是最好的方法。有没有办法从 php 访问我的 ssh 根目录?或者我的 ssh 的其他区域?

http://www.stellarwebsolutions.com/en/articles.php

I just got the .pem to work with paypal but I cannot find a way to access the .pem without putting it on my public_html/ folder which I know is probably not the best way of doing it. Is there a way of accessing the root of my ssh from php? or other areas of my ssh?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情感失落者 2024-12-24 21:04:41

您可以轻松访问 public_html 文件夹之外的任何文件,只需确保 Web 服务器用户可以访问该文件即可。例如:

$ls -l
total 8
-rw-r--r-- 1 www-data www-data   12 Nov 26 13:08 test.txt
drwxr-xr-x 2 www-data www-data 4096 Nov 26 13:11 www

以下 php 脚本正在读取 test.txt:

<?php

$file = $_SERVER['DOCUMENT_ROOT'] . "/../test.txt"; // relative path
//$file = "/opt/nguyen/test.txt"; //absolute path
$contents = file($file);
$string = implode($contents);

echo $string;

?>

您还可以将文件放入 public_html 文件夹中,并使用 .htaccess 拒绝访问:

<Files config.inc.php>
  order allow,deny
  deny from all
</Files>

You can easily access any file outside of your public_html folder, you just have to make sure that the file is accessible to the web server user. For instance:

$ls -l
total 8
-rw-r--r-- 1 www-data www-data   12 Nov 26 13:08 test.txt
drwxr-xr-x 2 www-data www-data 4096 Nov 26 13:11 www

And the following php script is reading the test.txt:

<?php

$file = $_SERVER['DOCUMENT_ROOT'] . "/../test.txt"; // relative path
//$file = "/opt/nguyen/test.txt"; //absolute path
$contents = file($file);
$string = implode($contents);

echo $string;

?>

You can also put your file in your public_html folder and deny access with a .htaccess:

<Files config.inc.php>
  order allow,deny
  deny from all
</Files>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文