为 'apache' 用户生成 SSH 密钥 [英] Generating SSH keys for 'apache' user

查看:43
本文介绍了为 'apache' 用户生成 SSH 密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Linux 中为 'apache' 用户添加 SSH 密钥?

How do I add SSH keys for 'apache' user in Linux?

背景

我正在尝试向 github 添加一个服务挂钩,以在我推送到我的存储库后通知一个 URL.我设置了以下 php 页面:

I am trying to add a service hook to github to notify a URL once I push to my repo. I have the following php page set up:

<?php `git pull origin master`;  

但是我得到以下输出:

sh: git: Permission denied

这是因为我为 github 访问生成的密钥是由我的root"用户生成的.但是,当我从 php 执行命令时,它是运行它的 'apache' 用户.

This is because the keys I generated for github access were generated by my 'root' user. However when I exectue a command from php it is the 'apache' user that runs it.

因此密钥不对应,拒绝拉取权限.

The keys therefore do not correspond and permission is denied to pull.

由于我无法从终端切换用户以将密钥生成为apache",因此我不太确定该怎么做.任何人都可以提出解决方案吗?

As I cannot switch user from the terminal to generate keys as 'apache', I am not too sure what to do. Can anyone suggest a solution?

推荐答案

root 用户可以试试 sudo -u apache ssh-keygen -t rsa

As you are root, you can try it sudo -u apache ssh-keygen -t rsa

这篇关于为 'apache' 用户生成 SSH 密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆