【问题标题】:SVN won't cache credentialsSVN 不会缓存凭据
【发布时间】:2011-07-01 00:56:31
【问题描述】:

我正在使用命令行 svn 客户端(版本 1.6.12,来自 Ubuntu 存储库),我似乎无法让它缓存我的用户凭据。我正在尝试访问 https svn 存储库(类似于https://subversion.FAKE.com/PROJECT)。我的这个 repo 的用户名与我的本地用户名不同。

这是 ~/.subversion/config 的 auth 部分

[auth]
### Set password stores used by Subversion. They should be
### delimited by spaces or commas. The order of values determines
### the order in which password stores are used.
### Valid password stores:
###   gnome-keyring        (Unix-like systems)
###   kwallet              (Unix-like systems)
###   keychain             (Mac OS X)
###   windows-cryptoapi    (Windows)
# password-stores = gnome-keyring
### 
### The rest of this section in this file has been deprecated.
### Both 'store-passwords' and 'store-auth-creds' can now be
### specified in the 'servers' file in your config directory.
### Anything specified in this section is overridden by settings
### specified in the 'servers' file.
### 
### Set store-passwords to 'no' to avoid storing passwords in the 
### auth/ area of your config directory.  It defaults to 'yes',
### but Subversion will never save your password to disk in
### plaintext unless you tell it to (see the 'servers' file).
### Note that this option only prevents saving of *new* passwords;
### it doesn't invalidate existing passwords.  (To do that, remove
### the cache files by hand as described in the Subversion book.)
store-passwords = yes 
### Set store-auth-creds to 'no' to avoid storing any subversion
### credentials in the auth/ area of your config directory.
### It defaults to 'yes'.  Note that this option only prevents
### saving of *new* credentials;  it doesn't invalidate existing
### caches.  (To do that, remove the cache files by hand.)
store-auth-creds = yes 

这里是 ~/.subversion/servers 的全局部分

[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
# http-proxy-host = defaultproxy.whatever.com
# http-proxy-port = 7000
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword
# http-compression = no
# http-auth-types = basic;digest;negotiate
# No http-timeout, so just use the builtin default.
# No neon-debug-mask, so neon debugging is disabled.
# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem
#
# Password / passphrase caching parameters:
store-passwords = yes
store-plaintext-passwords = no
store-auth-creds = yes
# store-ssl-client-cert-pp = no
# store-ssl-client-cert-pp-plaintext = no

我所做的唯一更改是明确设置一些与存储密码相关的选项。我尝试设置 password-stores = gnome-keyring 无效。此外,我删除了 ~/.subversion/auth (根据其他一些线程),它仍然没有被 svn 客户端重新创建。

有什么建议吗?如何强制 SVN 存储我的凭据(在 ~/.subversion/auth 或使用 gnome-keyring,我不在乎)。

【问题讨论】:

    标签: svn credentials


    【解决方案1】:

    subversion 的配置文件存在于用户区(你的主目录~/.subversion)和系统区(/etc/subversion),见http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.1。如果您有管理员权限,可以从系统文件中复制“config”和“servers”文件或直接编辑它们。

    最简单但不安全的解决方案是让 subversion 在纯文件中缓存凭据。为此,只需设置 store-passwords = yes 并将所有其他设置保留为默认设置(已注释)。

    使用 gnome-keyring 存储密码可能不起作用,因为该工具未安装或 gnome-keyring-daemon 可能未运行。

    【讨论】:

    • 感谢您的回复,但很遗憾没有成功。我尝试只设置store-passwords = yes,但什么也没发生(auth 目录仍未重新创建)。我什至尝试设置store-plaintext-passwords = yes,但仍然没有骰子。我在 /etc/subversion/* 和 ~/.subversion/* 中设置了所有这些选项
    【解决方案2】:

    不确定您是否还在此处寻找答案;但是“ssl-client-cert-password”选项可能是您正在寻找的选项。

    ssl-client-cert-password=<password>
    

    【讨论】:

    • 感谢答案,但我没有使用客户端 SSL 证书。
    【解决方案3】:

    不知道这个问题是否已经解决了,但是你有没有尝试添加

    password-stores = 
    

    到你的“配置”文件?

    【讨论】:

      【解决方案4】:

      你至少有三个选择

      1. 无密码设置 ssh (try this example)
      2. 使用 gnome 密钥环 (google search for 'svn gnome keyring password')。这通常归结为编辑您的 ~/.subversion/config file(password-stores = gnome-keyring 和 store-passwords = yes)。
      3. 以明文形式存储密码。

      要以明文形式存储密码,首先删除您的~/.subversion 目录。这将删除任何以前配置的项目,例如您已经接受的服务器证书和任何以前缓存的密码。下次运行 svn 时,它将重新创建一个“空白”目录结构。然后对您的存储库运行 svn 命令。您应该会看到类似于以下内容的内容:

      $> cd <project directory>
      $> svn update
      Error validating server certificate for 'https://...':
       - The certificate is not issued by a trusted authority. Use the
         fingerprint to validate the certificate manually!
      Certificate information:
       - Hostname: ...
       - Valid: ...
       - Issuer: ...
       - Fingerprint: ...
      (R)eject, accept (t)emporarily or accept (p)ermanently? p
      Password for 'your username': secret
      -----------------------------------------------------------------------
      ATTENTION!  Your password for authentication realm:
      
        <https://...> ...
      
      can only be stored to disk unencrypted!  You are advised to configure
      your system so that Subversion can store passwords encrypted, if
      possible.  See the documentation for details.
      
      You can avoid future appearances of this warning by setting the value
      of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
      '/home/.../.subversion/servers'.
      -----------------------------------------------------------------------
      Store password unencrypted (yes/no)? yes
      

      注意!!!这将以明文形式保存您的密码(非常不安全),但它也会缓存您的密码,因此您不必每次都输入密码。最终密码以明文形式存储在~/.subversion/auth/svn.simple/中。

      【讨论】:

        【解决方案5】:

        在您的配置中有一个选项store-plaintext-passwords = no,它不允许将密码存储在 $HOME/.subversion 中,除非有一些支持的加密可用。

        要恢复到 1.6 之前的行为,您可以将值更改为 yes,这样可以保存密码。

        【讨论】:

          【解决方案6】:

          如果提到的所有选项都设置正确,可能svn客户端由于权限而无法写入凭据文件。我发现这个线程遇到了相同的行为,并且权限是解决方法。

          【讨论】:

            猜你喜欢
            • 2011-03-04
            • 1970-01-01
            • 1970-01-01
            • 2017-07-21
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多