进击的前端

Linux下SVN账号密码保存方法

October 18, 2017

Linux下进行SVN操作的时候总是提示要输入密码,很不方便,尤其是集成到npm scripts上的时候,你不想明写密码,但是如果不写,每次都提示要输入密码,不同用户协作起来更加麻烦。

修改配置文件config

文件位置/home/[username]/.subversion/config

用vim打开

vim /home/[username]/.subversion/config

原配置文件:

### This file configures various client-side behaviors.
###
### The commented-out examples below are intended to demonstrate
### how to use this file.

### Section for authentication and authorization customizations.
[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)
###   gpg-agent            (Unix-like systems)
###   keychain             (Mac OS X)
###   windows-cryptoapi    (Windows)
# password-stores = gpg-agent,gnome-keyring,kwallet
### To disable all password stores, use an empty list:
# password-stores =
###
### Set KWallet wallet used by Subversion. If empty or unset,
### then the default network wallet will be used.
# kwallet-wallet =
###
### Include PID (Process ID) in Subversion application name when
### using KWallet. It defaults to 'no'.
# kwallet-svn-application-name-with-pid = yes
###
### Set ssl-client-cert-file-prompt to 'yes' to cause the client
### to prompt for a path to a client cert file when the server
### requests a client cert but no client cert file is found in the
### expected place (see the 'ssl-client-cert-file' option in the
### 'servers' configuration file). Defaults to 'no'.
# ssl-client-cert-file-prompt = no
###
### The rest of the [auth] 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
### and are documented there. Anything specified in this section
### is overridden by settings specified in the 'servers' file.
# store-passwords = no
# store-auth-creds = no

### Section for configuring external helper applications.
[helpers]
### Set editor-cmd to the command used to invoke your text editor.
###   This will override the environment variables that Subversion
###   examines by default to find this information ($EDITOR,
###   et al).
# editor-cmd = editor (vi, emacs, notepad, etc.)
editor-cmd = vim
### Set diff-cmd to the absolute path of your 'diff' program.
###   This will override the compile-time default, which is to use
###   Subversion's internal diff implementation.
# diff-cmd = diff_program (diff, gdiff, etc.)
diff-cmd = /usr/local/bin/svndiff.sh
### Diff-extensions are arguments passed to an external diff
### program or to Subversion's internal diff implementation.
### Set diff-extensions to override the default arguments ('-u').
# diff-extensions = -u -p
### Set diff3-cmd to the absolute path of your 'diff3' program.
###   This will override the compile-time default, which is to use
###   Subversion's internal diff3 implementation.
# diff3-cmd = diff3_program (diff3, gdiff3, etc.)
### Set diff3-has-program-arg to 'yes' if your 'diff3' program
###   accepts the '--diff-program' option.
# diff3-has-program-arg = [yes | no]
### Set merge-tool-cmd to the command used to invoke your external
### merging tool of choice. Subversion will pass 5 arguments to
### the specified command: base theirs mine merged wcfile
# merge-tool-cmd = merge_command

### Section for configuring tunnel agents.
[tunnels]
### Configure svn protocol tunnel schemes here.  By default, only
### the 'ssh' scheme is defined.  You can define other schemes to
### be used with 'svn+scheme://hostname/path' URLs.  A scheme
### definition is simply a command, optionally prefixed by an
### environment variable name which can override the command if it
### is defined.  The command (or environment variable) may contain
### arguments, using standard shell quoting for arguments with
### spaces.  The command will be invoked as:
###   <command> <hostname> svnserve -t
### (If the URL includes a username, then the hostname will be
### passed to the tunnel agent as <user>@<hostname>.)  If the
### built-in ssh scheme were not predefined, it could be defined
### as:
# ssh = $SVN_SSH ssh -q -o ControlMaster=no
### If you wanted to define a new 'rsh' scheme, to be used with
### 'svn+rsh:' URLs, you could do so as follows:
# rsh = rsh
### Or, if you wanted to specify a full path and arguments:
# rsh = /path/to/rsh -l myusername
### On Windows, if you are specifying a full path to a command,
### use a forward slash (/) or a paired backslash (\\) as the
### path separator.  A single backslash will be treated as an
### escape for the following character.

### Section for configuring miscellaneous Subversion options.
[miscellany]
### Set global-ignores to a set of whitespace-delimited globs
### which Subversion will ignore in its 'status' output, and
### while importing or adding files and directories.
### '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'.
# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo __pycache__
#   *.rej *~ #*# .#* .*.swp .DS_Store [Tt]humbs.db
### Set log-encoding to the default encoding for log messages
# log-encoding = latin1
### Set use-commit-times to make checkout/update/switch/revert
### put last-committed timestamps on every file touched.
# use-commit-times = yes
### Set no-unlock to prevent 'svn commit' from automatically
### releasing locks on files.
# no-unlock = yes
### Set mime-types-file to a MIME type registry file, used to
### provide hints to Subversion's MIME type auto-detection
### algorithm.
# mime-types-file = /path/to/mime.types
### Set preserved-conflict-file-exts to a whitespace-delimited
### list of patterns matching file extensions which should be
### preserved in generated conflict file names.  By default,
### conflict files use custom extensions.
# preserved-conflict-file-exts = doc ppt xls od?
### Set enable-auto-props to 'yes' to enable automatic properties
### for 'svn add' and 'svn import', it defaults to 'no'.
### Automatic properties are defined in the section 'auto-props'.
# enable-auto-props = yes
### Set interactive-conflicts to 'no' to disable interactive
### conflict resolution prompting.  It defaults to 'yes'.
# interactive-conflicts = no
### Set memory-cache-size to define the size of the memory cache
### used by the client when accessing a FSFS repository via
### ra_local (the file:// scheme). The value represents the number
### of MB used by the cache.
# memory-cache-size = 16
### Set diff-ignore-content-type to 'yes' to cause 'svn diff' to
### attempt to show differences of all modified files regardless
### of their MIME content type.  By default, Subversion will only
### attempt to show differences for files believed to have human-
### readable (non-binary) content.  This option is especially
### useful when Subversion is configured (via the 'diff-cmd'
### option) to employ an external differencing tool which is able
### to show meaningful differences for binary file formats.  [New
### in 1.9]
# diff-ignore-content-type = no

### Section for configuring automatic properties.
[auto-props]
### The format of the entries is:
###   file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?').  All entries which match (case-insensitively) will be
### applied to the file.  Note that auto-props functionality
### must be enabled, which is typically done by setting the
### 'enable-auto-props' option.
# *.c = svn:eol-style=native
# *.cpp = svn:eol-style=native
# *.h = svn:keywords=Author Date Id Rev URL;svn:eol-style=native
# *.dsp = svn:eol-style=CRLF
# *.dsw = svn:eol-style=CRLF
# *.sh = svn:eol-style=native;svn:executable
# *.txt = svn:eol-style=native;svn:keywords=Author Date Id Rev URL;
# *.png = svn:mime-type=image/png
# *.jpg = svn:mime-type=image/jpeg
# Makefile = svn:eol-style=native

### Section for configuring working copies.
[working-copy]
### Set to a list of the names of specific clients that should use
### exclusive SQLite locking of working copies.  This increases the
### performance of the client but prevents concurrent access by
### other clients.  Third-party clients may also support this
### option.
### Possible values:
###   svn                (the command line client)
# exclusive-locking-clients =
### Set to true to enable exclusive SQLite locking of working
### copies by all clients using the 1.8 APIs.  Enabling this may
### cause some clients to fail to work properly. This does not have
### to be set for exclusive-locking-clients to work.
# exclusive-locking = false
### Set the SQLite busy timeout in milliseconds: the maximum time
### the client waits to get access to the SQLite database before
### returning an error.  The default is 10000, i.e. 10 seconds.
### Longer values may be useful when exclusive locking is enabled.
# busy-timeout = 10000

找到:

# store-passwords = no

改为:

store-passwords = yes

保存,下次SVN操作的时候需要输入一次密码,之后就不用再输密码了。

切换SVN账号

有时候需要切换SVN账号进行相应的操作,但是默认提示的是上一次操作的账号。碰到这个问题,只要删除/home/[username]/.subversion/auth即可。

rm -rf /home/[username]/.subversion/auth

保存,下次SVN操作的时候就会提示输入用户名。

修改配置文件servers

如果上面的方法没有解决每次都要输入密码的问题,可以继续修改servers配置文件。

用vim打开文件:

vim /home/[username]/.subversion/servers

原文件内容如下:

### This file specifies server-specific parameters,
### including HTTP proxy information, HTTP timeout settings,
### and authentication settings.
###
### The currently defined server options are:
###   http-proxy-host            Proxy host for HTTP connection
###   http-proxy-port            Port number of proxy host service
###   http-proxy-username        Username for auth to proxy service
###   http-proxy-password        Password for auth to proxy service
###   http-proxy-exceptions      List of sites that do not use proxy
###   http-timeout               Timeout for HTTP requests in seconds
###   http-compression           Whether to compress HTTP requests
###   http-max-connections       Maximum number of parallel server
###                              connections to use for any given
###                              HTTP operation.
###   http-chunked-requests      Whether to use chunked transfer
###                              encoding for HTTP requests body.
###   neon-debug-mask            Debug mask for Neon HTTP library
###   ssl-authority-files        List of files, each of a trusted CA
###   ssl-trust-default-ca       Trust the system 'default' CAs
###   ssl-client-cert-file       PKCS#12 format client certificate file
###   ssl-client-cert-password   Client Key password, if needed.
###   ssl-pkcs11-provider        Name of PKCS#11 provider to use.
###   http-library               Which library to use for http/https
###                              connections.
###   http-bulk-updates          Whether to request bulk update
###                              responses or to fetch each file
###                              in an individual request.
###   store-passwords            Specifies whether passwords used
###                              to authenticate against a
###                              Subversion server may be cached
###                              to disk in any way.
###   store-plaintext-passwords  Specifies whether passwords may
###                              be cached on disk unencrypted.
###   store-ssl-client-cert-pp   Specifies whether passphrase used
###                              to authenticate against a client
###                              certificate may be cached to disk
###                              in any way
###   store-ssl-client-cert-pp-plaintext
###                              Specifies whether client cert
###                              passphrases may be cached on disk
###                              unencrypted (i.e., as plaintext).
###   store-auth-creds           Specifies whether any auth info
###                              (passwords, server certs, etc.)
###                              may be cached to disk.
###   username                   Specifies the default username.
###
### Set store-passwords to 'no' to avoid storing passwords on disk
### in any way, including in password stores.  It defaults to
### 'yes', but Subversion will never save your password to disk in
### plaintext unless explicitly configured to do so.
### 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.)
###
### Set store-plaintext-passwords to 'no' to avoid storing
### passwords in unencrypted form in the auth/ area of your config
### directory. Set it to 'yes' to allow Subversion to store
### unencrypted passwords in the auth/ area.  The default is
### 'ask', which means that Subversion will ask you before
### saving a password to disk in unencrypted form.  Note that
### this option has no effect if either 'store-passwords' or
### 'store-auth-creds' is set to 'no'.
###
### Set store-ssl-client-cert-pp to 'no' to avoid storing ssl
### client certificate passphrases in the auth/ area of your
### config directory.  It defaults to 'yes', but Subversion will
### never save your passphrase to disk in plaintext unless
### explicitly configured to do so.
###
### Note store-ssl-client-cert-pp only prevents the saving of *new*
### passphrases; it doesn't invalidate existing passphrases.  To do
### that, remove the cache files by hand as described in the
### Subversion book at http://svnbook.red-bean.com/nightly/en/\
###                    svn.serverconfig.netmodel.html\
###                    #svn.serverconfig.netmodel.credcache
###
### Set store-ssl-client-cert-pp-plaintext to 'no' to avoid storing
### passphrases in unencrypted form in the auth/ area of your
### config directory.  Set it to 'yes' to allow Subversion to
### store unencrypted passphrases in the auth/ area.  The default
### is 'ask', which means that Subversion will prompt before
### saving a passphrase to disk in unencrypted form.  Note that
### this option has no effect if either 'store-auth-creds' or
### 'store-ssl-client-cert-pp' is set to 'no'.
###
### Set store-auth-creds to 'no' to avoid storing any Subversion
### credentials in the auth/ area of your config directory.
### Note that this includes SSL server certificates.
### 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.)
###
### HTTP timeouts, if given, are specified in seconds.  A timeout
### of 0, i.e. zero, causes a builtin default to be used.
###
### Most users will not need to explicitly set the http-library
### option, but valid values for the option include:
###    'serf': Serf-based module (Subversion 1.5 - present)
###    'neon': Neon-based module (Subversion 1.0 - 1.7)
### Availability of these modules may depend on your specific
### Subversion distribution.
###
### The commented-out examples below are intended only to
### demonstrate how to use this file; any resemblance to actual
### servers, living or dead, is entirely coincidental.

### In the 'groups' section, the URL of the repository you're
### trying to access is matched against the patterns on the right.
### If a match is found, the server options are taken from the
### section with the corresponding name on the left.

[groups]
# group1 = *.collab.net
# othergroup = repository.blarggitywhoomph.com
# thirdgroup = *.example.com

### Information for the first group:
# [group1]
# http-proxy-host = proxy1.some-domain-name.com
# http-proxy-port = 80
# http-proxy-username = blah
# http-proxy-password = doubleblah
# http-timeout = 60
# neon-debug-mask = 130
# store-plaintext-passwords = no
# username = harry

### Information for the second group:
# [othergroup]
# http-proxy-host = proxy2.some-domain-name.com
# http-proxy-port = 9000
# No username and password for the proxy, so use the defaults below.

### You can set default parameters in the 'global' section.
### These parameters apply if no corresponding parameter is set in
### a specifically matched group as shown above.  Thus, if you go
### through the same proxy server to reach every site on the
### Internet, you probably just want to put that server's
### information in the 'global' section and not bother with
### 'groups' or any other sections.
###
### Most people might want to configure password caching
### parameters here, but you can also configure them per server
### group (per-group settings override global settings).
###
### If you go through a proxy for all but a few sites, you can
### list those exceptions under 'http-proxy-exceptions'.  This only
### overrides defaults, not explicitly matched server names.
###
### 'ssl-authority-files' is a semicolon-delimited list of files,
### each pointing to a PEM-encoded Certificate Authority (CA)
### SSL certificate.  See details above for overriding security
### due to SSL.
[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
# 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 = no
# store-ssl-client-cert-pp = no
# store-plaintext-passwords = no
# store-ssl-client-cert-pp-plaintext = no

找到:

# store-passwords = no
# store-plaintext-passwords = no

修改为:

store-passwords = yes
store-plaintext-passwords = yes

保存,下次操作的时候就不用输入SVN密码了。


Kyle Mathews

Written by ricosmall.
Github