![](/img/trans.png)
[英]How can store ftp's username and password in android with securely way
[英]what's the best way to store username/password for Ant SCP task
我需要使用 scp 任务来传输包含许多子文件夹和文件的整个文件夹。 目前我使用以下方式:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/yy" />
<scp file="user:password@host:/home/xx/yy/*" todir="${project.build.directory}/yy" trust="yes"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.7.1</version>
</dependency>
</dependencies>
</plugin>
如果我对用户名和密码进行硬编码,它也可以工作。 但我不想在代码库中公开它。 所以我将它存储在 maven-settings.xml 中,如下所示:
pom.xml
<scp file="${scpUserName}:${scpUserPassword}@company.net:/home/xx/yy/*" todir="${project.build.directory}/yy" trust="yes"/>
设置.xml
<profiles>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<scpUserName>xxx</scpUserName>
<scpUserPassword>xxx</scpUserPassword>
</properties>
</profile>
</profiles>
但是我仍然需要在 Teamcity 服务器中公开用户名/密码,以便所有代理服务器都可以成功构建整个项目。 我想知道是否有更好的方法?
Maven 文档解释了。 首先创建一个主密码
mvn --encrypt-master-password <password>
将结果输入settings-security.xml
<settingsSecurity>
<master>the result here</master>
</settingsSecurity>
对于个人密码,像这样加密
mvn --encrypt-password <password>
你可以直接在你的 Maven 插件中使用它
<properties>
<scpUserName>xxx<sscpUserName>
<scpUserPassword>the result here</scpUserPassword>
</properties>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.