如何设置Linux服务器以连接到存储库?

发布于 2025-02-11 15:00:46 字数 453 浏览 1 评论 0 原文

我是一个相对缺乏经验的开发人员,试图接管以前编码人员的网站的开发。

该代码存在于GitHub上的存储库上,该网站托管在Linux服务器上。我可以以非root用户的形式远程记录到服务器中,并运行 sudo git pull origin master 命令,但由于github的许可拒绝了错误,因此它无法正常工作。已经有一个〜/.ssh 带有 euthorized_keys 的目录, nown_hosts 以及 id_rsa files。

我已经尝试将密钥添加到我的GitHub帐户中,并且还尝试使用新生成的密钥,但它不起作用,我什至不确定是否应该在我的帐户中添加这些密钥。我的帐户确实可以访问存储库,但是我不确定这是否是其工作方式。

谁能告诉我我需要做什么,以使我有可能将代码从GitHub存储库提取到此远程服务器?

I am a relatively inexperienced developer trying to take over the development of a website from the previous coders.

The code exists on a repository on Github and the website is hosted on a Linux server. I can log remotely into the server as a non-root user and run a sudo git pull origin master command but it won't work because of a permission denied error from Github. There is already an ~/.ssh directory with authorized_keys, known_hosts as well as id_rsa files.

I've tried adding the keys there to my Github account and also tried using newly generated keys but it didn't work and I'm not even sure if adding these keys to my account is supposed to work. My account does have access to the repository, but I'm not sure if that is how it works.

Could anyone tell me what I need to do in order to make it possible for me to pull the code from the Github repository to this remote server?

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

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

发布评论

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

评论(1

空袭的梦i 2025-02-18 15:00:46

如果您使用sudo运行命令,则使用存储在/root 的凭据。
确保:

  • 命令 git Remote -V 在存储库文件夹中执行的命令( [email  procected] :auser/asepository
  • ssh键
  • ssh ssh in < -code> ssh ssh in < -ssh a href =“/cdn-cgi/l/电子邮件保护” class =“ __ cf_email__” data-cfemail =“ 395E504D795E504D514C5B175A5654”>
    您应该看到一个欢迎消息:

     嗨,我! 
    您已经成功验证了,但是GitHub不提供Shell访问权限。
     

通常,如果您使用远程用户帐户而不是远程 root 帐户进行所有这些命令,那会更好。


讨论,看来:

  • sudo不需要
  • 键, /home/company_name
  • /home/company_name/.ssh 需要需要修复< /a>

What the OP had:

-rw-r--r-- 1 [company_name] [company_name] 2.2K Mar 8 2019 known_hosts
-rw-rw-r-- 1 [company_name] [company_name] 38 Mar 8 2019 config
-rw------- 1 [company_name] [company_name] 755 Mar 17 2019 authorized_keys
-rw-r--r-- 1 [company_name] [company_name] 402 Dec 6 2019 id_rsa.pub
-rw------- 1 [company_name] [company_name] 1.7K Dec 6 2019 id_rsa
-rw-r--r-- 1 [company_name] [company_name] 746 Jun 29 08:46 id_rsa_samson.pub
-rw------- 1 [company_name] [company_name] 3.2K Jun 29 08:46 id_rsa_samson
drwx------ 2 [company_name] [company_name] 4.0K Jun 29 08:46 .
drwxr-xr-x 15 [company_name] [company_name] 4.0K Jun 29 09:20 ..

Versus the right permissions for SSH:

Path Permission
.ssh directory ( 0700(drwx -------)
私钥(ex: id_rsa )(
config 0600(-rw --------)
public键(*.pub ex: id_rsa.pub 0644(-rw-r-r--r--r---- )
授权> 0644(-rw-r--r---)
nown_hosts 0644(-rw-r--r-- r--)

从那里,ssh -tv [email&nbsp; procected] 确实显示了预期的欢迎消息您已经成功验证了,但是GitHub不提供外壳访问。

任何 git clone/push/pull 都可以使用(再次,无需 sudo 需要)

If you run the command with sudo, you are using credentials stored in /root.
Make sure that:

  • The command git remote -v executed in the repository folder shows you an SSH URL ([email protected]:aUser/aRepository)
  • The SSH keys are in /root/.ssh
  • The authentication work with sudo ssh -Tv [email protected].
    You should see a welcome message like:

    Hi Me! 
    You've successfully authenticated, but GitHub does not provide shell access.
    

In general, it would be better if you do all those command with a remote user account instead of the remote root account.


After discussion, it appears that:

  • sudo is not needed
  • keys are in /home/company_name
  • permissions of /home/company_name/.ssh need to be fixed

What the OP had:

-rw-r--r-- 1 [company_name] [company_name] 2.2K Mar 8 2019 known_hosts
-rw-rw-r-- 1 [company_name] [company_name] 38 Mar 8 2019 config
-rw------- 1 [company_name] [company_name] 755 Mar 17 2019 authorized_keys
-rw-r--r-- 1 [company_name] [company_name] 402 Dec 6 2019 id_rsa.pub
-rw------- 1 [company_name] [company_name] 1.7K Dec 6 2019 id_rsa
-rw-r--r-- 1 [company_name] [company_name] 746 Jun 29 08:46 id_rsa_samson.pub
-rw------- 1 [company_name] [company_name] 3.2K Jun 29 08:46 id_rsa_samson
drwx------ 2 [company_name] [company_name] 4.0K Jun 29 08:46 .
drwxr-xr-x 15 [company_name] [company_name] 4.0K Jun 29 09:20 ..

Versus the right permissions for SSH:

Path Permission
.ssh directory (code) 0700 (drwx------)
private keys (ex: id_rsa) (code) 0600 (-rw-------)
config 0600 (-rw-------)
public keys (*.pub ex: id_rsa.pub) 0644 (-rw-r--r--)
authorized_keys (code) 0644 (-rw-r--r--)
known_hosts 0644 (-rw-r--r--)

From there, a ssh -Tv [email protected] does display the expected welcome message Hi <You>! You've successfully authenticated, but GitHub does not provide shell access.

Any git clone/push/pull will work (again, no sudo needed)

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