【问题标题】:could not read Username for 'https://gitlab.com': No such device or address on Gitlab CI无法读取“https://gitlab.com”的用户名:Gitlab CI 上没有此类设备或地址
【发布时间】:2021-10-23 14:20:08
【问题描述】:

我正在尝试在我的节点项目中集成 gitlab CI,我有 SSH 访问权限,但我的脚本因错误而停止:

fatal: could not read Username for 'https://gitlab.com': No such device or address
debug2: channel 0: written 83 to efd 7
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: channel 0: chan_shutdown_write (i3 o1 sock -1 wfd 6 efd 7 [write])
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/7 sock -1 cc -1)
debug3: send packet: type 1
debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
debug1: fd 2 clearing O_NONBLOCK
Transferred: sent 3560, received 3156 bytes, in 0.7 seconds
Bytes per second: sent 5437.2, received 4820.2
debug1: Exit status 1
Cleaning up file based variables
00:01 ERROR: Job failed: exit code 1

我已经试过了

git config --global credential.helper store

git config --global user.password "myPassword"

git config --global user.email "myEmail"
  • 我看到 git 不提供无交互选项...

  • 图像:节点:debian 服务器的最新版本

  • 我的 ssh 凭据和访问都正常

  • 当我直接在服务器上测试时,它仍然会询问我的连接信息

  • 这是一个私人仓库

【问题讨论】:

  • user.password 未使用。永远不要设置它,因为它通常可读任何人,您通常不应该将您的密码存储在任何人都可以看到的地方。但是 Git 从不 looks 在这个值上(它读取文件并看到它并把它扔掉,因为它没有寻找任何名为 user.password 的东西),所以你所做的只是用大而清晰的字母写下你的密码,每个人 除了 Git 都会看到它。 ??????
  • 同时:httphttps 存在 凭证助手,但是当使用 ssh 时,Git 将操作交给单独的 ssh 命令,该命令根本不使用 Git 的凭证助手。所以credential.helper 设置不相关除非你要求Git 使用httphttps(你似乎在这里做)。最后,user.email 设置在您运行 git commit(仅)时使用,而不是在您运行 git push 时使用。

标签: node.js git deployment continuous-integration gitlab-ci


【解决方案1】:

尝试使用以下命令更改服务器上的 repo 来源:

git remote set-url origin https://username:access_token_or_password@gitlab.com/path_to_your_repo/repo.git

这样它在 git pull 或 git push 时不会要求提供凭据

【讨论】:

  • 感谢您的回复!使用您的命令,我收到以下消息:错误:将对象添加到存储库数据库 .git/objects 的权限不足。有没有办法不通过与 git 相关的协议,而是通过经典的 https ?
  • 现在可以了,需要执行set-url origin命令,以及更改.git文件及其组件的权限,并设置组mod!非常感谢!
  • 很高兴它有帮助:)
猜你喜欢
  • 1970-01-01
  • 2013-09-24
  • 2013-03-22
  • 2019-06-24
  • 2019-07-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多