当前位置: 首页 > news >正文

Linux下SVN客户端保存账号密码

参考文章:解决:Linux上SVN 1.12版本以上无法直接存储明文密码_linux svn 保存密码-CSDN博客
新版本svn使用gpg-agent存储密码-CSDN博客
svn之无法让 SVN 存储密码,即使配置设置为允许_编程设计_ITGUEST

方法一:明文方式保存密码

首次执行svn check或svn update等命令后,会在系统用户目录下生成.subversion目录,并在.subversion/auth/svn.simple目录下生成SVN用户的配置文件,比如:cdf4a82409609b47a18c1b93ad8db39c,文件内容如下:

steven@ubuntu2204:~$ cat "~/.subversion/auth/svn.simple/cdf4a82409609b47a18c1b93ad8db39c"
K 8
passtype
V 9
gpg-agent
K 15
svn:realmstring
V 52
<https://192.168.121.240> Subversion Repository
K 8
username
V 6
steven
END

修改.subversion/auth/svn.simple/cdf4a82409609b47a18c1b93ad8db39c文件,如下:

steven@ubuntu2204:~$ vi "~/.subversion/auth/svn.simple/cdf4a82409609b47a18c1b93ad8db39c"
steven@ubuntu2204:~$ cat "~/.subversion/auth/svn.simple/cdf4a82409609b47a18c1b93ad8db39c"
K 8
passtype
V 6
simple
K 15
svn:realmstring
V 52
<https://192.168.121.240:5443> Subversion Repository
K 8
username
V 6
steven
K 8
password
V 7
pwd1234
END

修改说明:
1.文件中K表示关键字,V表示键值,后面的数字表示下一行字符串的长度。
2.将密码保存方式由gpg-agent改为simple(明文)
3.添加steven用户密码: pwd1234

需要注意的是:若是换个SVN用户名后这个文件会被改写,以上手动修改的信息会被覆盖,需要从再手动修改。

方式二:gpg-agent加密保存

gpg-agent是一个密码管理工具,具体说明查看官网信息。
https://www.gnupg.org/

1.安装gpg-agent:

steven@ubuntu2204:~$ sudo apt-get install gpg-agent
gpg-agent (GnuPG) 2.2.27
libgcrypt 1.8.8
Copyright (C) 2021 Free Software Foundation, Inc.
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

2.添加环境变量:

修改shell初始化脚本,添加GPG_TTY和GPG_AGENT_INFO两个环境变量。并使用source命令让其立即生效。

steven@ubuntu2204:~$ vi ~/.bashrc
steven@ubuntu2204:~$ cat ~/.bashrc
... ...
export GPG_TTY=$(tty)
export GPG_AGENT_INFO=`gpgconf --list-dirs agent-socket | tr -d '\n' && echo -n ::`
steven@ubuntu2204:~$ source ~/.bashrc

3.配置gpg-agent

steven@ubuntu2204:~$ vi "~/.gunpg/gpg-agent.conf"
steven@ubuntu2204:~$ cat "~/.gunpg/gpg-agent.conf"
# ╔═══════════════════════════════════════════════════════════════════════════╗
# ║ gpg-agent configuration (~/.gnupg/gpg-agent.conf)                         ║
# ║                                                                           ║
# ║ Note:                                                                     ║
# ║ After changing the configuration, reload the agent:                       ║
# ║   $ gpg-connect-agent reloadagent /bye                                    ║
# ╚═══════════════════════════════════════════════════════════════════════════╝# Time a cache entry is valid (in seconds) default: 600
# Each time a cache entry is accessed, the entry's timer is reset
default-cache-ttl 172800# Set the maximum time a cache entry is valid to n seconds.
# After this time a cache entry will be expired even if it has been accessed recently.
# The default is 2 hours (7200 seconds).
max-cache-ttl 604800steven@ubuntu2204:~$ gpg-connect-agent reloadagent /bye

4.删除旧的SVN账号信息

steven@ubuntu2204:~$ rm -rf ~/.subversion

5.执行效果

steven@ubuntu2204:~$ svn update svntest
Updating 'steven.hu/svntest':
Error validating server certificate for 'https://192.168.121.240':- The certificate is not issued by a trusted authority. Use thefingerprint to validate the certificate manually!- The certificate hostname does not match.
Certificate information:- Hostname: xxxx- Valid: from Mar 24 14:32:41 2020 GMT until Mar 22 14:32:41 2030 GMT- Issuer: xxx- Fingerprint: xxx
(R)eject, accept (t)emporarily or accept (p)ermanently? p
Authentication realm: <https://192.168.121.240> Subversion Repository
Password for 'steven': ┌─────────────────────────────────────────────────────────────────────────────────────────┐
│ Enter your Subversion password for <https://192.168.121.240:5443> Subversion Repository │
│                                                                                         │
│ Password for 'steven':  ******_________________________________________________________ │
│                                                                                         │
│             <OK>                                                     <Cancel>           │
└─────────────────────────────────────────────────────────────────────────────────────────┘At revision 39.
steven@ubuntu2204:~$ svn update svntest
Updating 'svntest':
At revision 39.
steven@ubuntu2204:~$ 

http://www.lryc.cn/news/502890.html

相关文章:

  • centos7.9 gcc升级到11.2.1
  • HQChart使用教程30-K线图如何对接第3方数据42-DRAWTEXTREL,DRAWTEXTABS数据结构
  • 数仓高频面试 | 数仓为什么要分层
  • 网络安全—部署CA证书服务器
  • MATLAB中circshift函数的原理分析——psf2otf函数的核心
  • js 惰性函数
  • 智能技术引领未来:自动图像标注的创新应用与发展
  • 深入探索数据库世界:SQLite、Redis、MySQL 与数据库设计范式
  • 内网是如何访问到互联网的(华为源NAT)
  • 华为无线AC、AP模式与上线解析(Huawei Wireless AC, AP Mode and Online Analysis)
  • 奖励模池化
  • 基于django协同过滤的音乐推荐系统的设计与实现
  • Tiptap,: 富文本编辑器入门与案例分析
  • 使用Linux的logrotate工具切割日志:Tomcat、NGINX(journal文件清理)
  • CSS系列(11)-- 滤镜与混合模式详解
  • linux - 存储管理
  • 在 Kibana 中为 Vega Sankey 可视化添加过滤功能
  • styled-components 库的用法介绍和实践总结
  • SSE(Server-Sent Events)主动推送消息
  • pandas.core.frame.DataFrame怎么进行对象内容的读写
  • 短作业优先调度算法
  • SpringBoot 应用并发处理请求数的深入解析
  • MetaGPT中的教程助手:TutorialAssistant
  • 介绍一款docker ui 管理工具
  • 0022 基于SpringBoot的婚纱摄影线上预约系统的设计与实现
  • uni-app在image上绘制点位并回显
  • Comparator.comparing 排序注意
  • PPO系列3 - PPO原理
  • .idea
  • 单片机:实现呼吸灯(附带源码)