如何在 Linux 上保存 github 的登录凭据?

问题描述 投票:0回答:2

我在 Ubuntu/Debian 机器上使用 git。 我知道如何配置存储库的用户信息(姓名、邮件)。 但对于私有 github 存储库,每次我向远程推送或从远程拉取时,它总是需要一个令牌。 这是重复的,所以我想知道是否有解决方案。我认为令牌可以保存在某个地方并自动登录,就像Window上的github桌面一样。

我搜索了谷歌但没有找到解决方案。

非常感谢您的建议!

ubuntu github credentials
2个回答
1
投票

SSH 是最合适的方法,但是,您可以使用 git 凭证来存储:

  • 暂时
    $git config credential.helper 'cache [<options>]'

  • 永久
    $git config credential.helper 'store [<options>]'

0
投票

遵循 Github 关于 SSH 密钥的官方说明 对我有用 它包含 2 个步骤:

  1. 生成新的 SSH 密钥
    ssh-keygen -t ed25519 -C "[email protected]"
    > Generating public/private ALGORITHM key pair.
    > Enter a file in which to save the key (/home/YOU/.ssh/id_ALGORITHM):[Press enter]
    > Enter passphrase (empty for no passphrase): [Type a passphrase]
    > Enter same passphrase again: [Type passphrase again]
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_ed25519
    
  2. 将新的 SSH 密钥添加到您的 GitHub 帐户
    cat ~/.ssh/id_ed25519.pub
    # Then select and copy the contents of the id_ed25519.pub file
    # displayed in the terminal to your clipboard
    

© www.soinside.com 2019 - 2024. All rights reserved.