SSH GitLab pull 总是要求输入密码
SSH GitLab pull always asks for password
(GitLab 特别是!(GitHub 没有问题))
我正在尝试创建一个脚本来从 main
GitLab 分支中提取项目而不要求输入密码。几台远程计算机有一个信息亭模式项目。总是手动连接到它们有点无聊 - 而不是让 cron-job 自动拉取 .
我已设置使用 SSH 并创建并添加了我的 SSH ed25519 密钥。
在 ./.git/config
中添加了正确的 url
,例如:
[remote "origin"]
url = git@gitlab.com:<ME>/<REPO>.git
其中 <ME>
和 <REPO>
是我的用户名和存储库:)
使用 git pull
或 fetch
总是 要求输入密码 。我的 GitHub 存储库没有发生同样的情况。
我设法让它工作的唯一方法是使用 Personal Access Token 比如:
[remote "origin"]
url = https://oauth2:<MY P. A. TOKEN>@gitlab.com/<ME>/<REPO>.git
但我不喜欢令牌是纯文本的,并且不得不做超出 SSH 握手范围的事情。
我缺少某些 GitLab 特定的东西吗?我能够搜索到的每个帮助页面都只是谈论设置正确的 SSH URI(git@gitlab.com..... 等),我已经这样做了。但是每次我触发 git pull
它 一直要求输入密码 .
Windows。 Git Bash.
感谢任何帮助、技巧或见解。
您的 ssh 密钥是使用密码短语生成的,这就是它要求您提供密码短语的原因。
无密码SSH登录
你的目标
您想使用 Linux 和 OpenSSH 来自动执行您的任务。因此,您需要从主机 A/用户 a 自动登录到主机 B/用户 b。您不想输入任何密码,因为您想从 shell 脚本中调用 ssh。
怎么做
首先以用户 a 登录 A 并生成一对认证密钥。不要输入密码:
a@A:~> ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase: (THIS IS THE CATCH, just press enter here to leave it empty):
Enter same passphrase again: (press enter again)
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
a@A:~> ssh-copy-id remote_username@remote_domain
or
a@A:~> ssh-copy-id remote_username@remote_IP
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
remote_username@remote_domain password:
在那里它会要求您输入该远程服务器上远程用户的密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh -p '22' 'remote_username@remote_domain'"
and check to make sure that only the key(s) you wanted were added.
现在尝试使用
登录
a@A:~> ssh remote_username@remote_domain
你应该进去
我在 Windows 上遇到了同样的问题,即使 ssh -T git@gitlab.domain.com 也不起作用!
解决方案比我想象的要简单得多:我必须以管理员身份打开 git bash
(GitLab 特别是!(GitHub 没有问题))
我正在尝试创建一个脚本来从 main
GitLab 分支中提取项目而不要求输入密码。几台远程计算机有一个信息亭模式项目。总是手动连接到它们有点无聊 - 而不是让 cron-job 自动拉取 .
我已设置使用 SSH 并创建并添加了我的 SSH ed25519 密钥。
在 ./.git/config
中添加了正确的 url
,例如:
[remote "origin"]
url = git@gitlab.com:<ME>/<REPO>.git
其中 <ME>
和 <REPO>
是我的用户名和存储库:)
使用 git pull
或 fetch
总是 要求输入密码 。我的 GitHub 存储库没有发生同样的情况。
我设法让它工作的唯一方法是使用 Personal Access Token 比如:
[remote "origin"]
url = https://oauth2:<MY P. A. TOKEN>@gitlab.com/<ME>/<REPO>.git
但我不喜欢令牌是纯文本的,并且不得不做超出 SSH 握手范围的事情。
我缺少某些 GitLab 特定的东西吗?我能够搜索到的每个帮助页面都只是谈论设置正确的 SSH URI(git@gitlab.com..... 等),我已经这样做了。但是每次我触发 git pull
它 一直要求输入密码 .
Windows。 Git Bash.
感谢任何帮助、技巧或见解。
您的 ssh 密钥是使用密码短语生成的,这就是它要求您提供密码短语的原因。
无密码SSH登录
你的目标
您想使用 Linux 和 OpenSSH 来自动执行您的任务。因此,您需要从主机 A/用户 a 自动登录到主机 B/用户 b。您不想输入任何密码,因为您想从 shell 脚本中调用 ssh。
怎么做 首先以用户 a 登录 A 并生成一对认证密钥。不要输入密码:
a@A:~> ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase: (THIS IS THE CATCH, just press enter here to leave it empty):
Enter same passphrase again: (press enter again)
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
a@A:~> ssh-copy-id remote_username@remote_domain
or
a@A:~> ssh-copy-id remote_username@remote_IP
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
remote_username@remote_domain password:
在那里它会要求您输入该远程服务器上远程用户的密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh -p '22' 'remote_username@remote_domain'"
and check to make sure that only the key(s) you wanted were added.
现在尝试使用
登录a@A:~> ssh remote_username@remote_domain
你应该进去
我在 Windows 上遇到了同样的问题,即使 ssh -T git@gitlab.domain.com 也不起作用! 解决方案比我想象的要简单得多:我必须以管理员身份打开 git bash