之前 git clone [email protected]:namespace/project.git 的时候,如果没设置好 SSH key,会提示输入密码,很多用户对此感到迷惑。现在在 sshd_config 中加了下面两行,会直接提示访问被拒绝。

Match User git
PasswordAuthentication no

Tips:GitLab 的代码仓库支持 SSH 和 HTTPS 两种访问方式:

  1. SSH 访问,需要用 ssh-keygen 生成密钥,把公钥(id_rsa.pub)添加到 GitLab 个人管理区域的 public key。
  2. HTTPS 访问,每次连接服务器都要输入用户名(注册邮箱)和密码。可以作为在公用电脑上的临时访问方式。