You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Eclipse中向Debian VPS的Git远程仓库推送代码遇权限问题求助

Fixing Git Push Access Denied with SSH on Debian VPS

Got it, let's get this push issue sorted out quickly. The root problem here is straightforward: the git:// protocol is read-only—it works perfectly for cloning or pulling code, but it doesn't support pushing changes because it has no way to handle authentication. Since you already have SSH access to your Debian VPS, we just need to switch your local repo's remote URL to use SSH instead, and make sure a few basics are set up on the server side.

Step 1: Confirm your VPS repo is a bare repository

First, SSH into your Debian VPS to check if your Git repo is set up correctly for pushes. Regular Git repos (with a working directory) don't allow pushes by default—you need a "bare" repo (no working files, just the Git metadata):

  • Connect to your VPS via SSH:
    ssh your-username@myWebsite.com
    
  • If your existing repo is a regular one (you see files like README.md alongside a .git folder), convert it to a bare repo with:
    git clone --bare /path/to/your/current/repo myRepository.git
    
  • This will create a new myRepository.git folder (the bare repo) that's ready to accept pushes. Note its absolute path (e.g., /home/your-username/myRepository.git).

Step 2: Update the remote URL in Eclipse

Now let's point your local Eclipse project to use the SSH URL instead of git://:

  • Open your project in Eclipse, then open the Git Repositories view: Go to Window > Show View > Other..., then select Git > Git Repositories.
  • In the Git Repositories view, expand your project's repo, then expand Remotes > origin.
  • Right-click on origin and select Properties (or Configure Push... depending on your Eclipse version).
  • In the URI field, replace git://myWebsite.com/myRepository.git with your SSH URI, which follows this format:
    your-username@myWebsite.com:/path/to/your/bare/repo/myRepository.git
    
    For example: jane@myWebsite.com:/home/jane/myRepository.git
  • Save the changes.

Step 3: Test the push

Make a tiny test change to your code (like adding a comment to a file), stage and commit it as you normally would in Eclipse. Then try pushing again—Eclipse should prompt you for your VPS SSH password (if you haven't set up key-based auth). If all goes well, the push will succeed!

Bonus: Set up SSH key-based authentication (no more passwords!)

To make pushes even smoother, set up SSH keys so you don't have to enter your password every time:

  • On your local machine, generate an SSH key if you don't already have one:
    ssh-keygen -t ed25519
    
    Just press Enter through all prompts (you can add a passphrase for extra security if you want).
  • Copy your public key to the VPS:
    ssh-copy-id your-username@myWebsite.com
    
  • From now on, Eclipse will use your SSH key to authenticate automatically when pushing.

内容的提问来源于stack exchange,提问作者Errore Fatale

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:27:10