Git SSH configuration using properties

By default, Spring Cloud Config Server uses SSH configuration files such
as ~/.ssh/known_hosts and /etc/ssh/ssh_config when connecting to Git repositories
using an SSH URI. In cloud environments such as Cloud Foundry,
the local filesystem may be ephemeral or not easily accessible.

 For cases such as these, SSH configuration can be set using Java properties.
 In order to activate property based SSH configuration,
the property spring.cloud.config.server.git.ignoreLocalSshSettings must be set to true
This commit is contained in:
Ollie Hughes
2017-07-06 16:21:09 +01:00
parent d56926eba6
commit acee8a1b10
18 changed files with 1513 additions and 63 deletions

View File

@@ -6,8 +6,10 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config</artifactId>
<version>1.3.2.BUILD-SNAPSHOT</version>
<version>1.4.0.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<packaging>pom</packaging>
<name>Spring Cloud Config Docs</name>
<description>Spring Cloud Docs</description>

View File

@@ -360,7 +360,77 @@ by the default credential provider chain. AWS EC2 instances may use
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html[IAM Roles for EC2 Instances].
Note: The aws-java-sdk-core jar is an optional dependency. If the aws-java-sdk-core jar is not on your
classpath, then the AWS Code Commit credential provider will not be created regardless of the git server URI.
classpath, then the AWS Code Commit credential provider will not be created regardless of the git server URI.
===== Git SSH configuration using properties
By default, Spring Cloud Config Server uses SSH configuration files such as `~/.ssh/known_hosts` and `/etc/ssh/ssh_config` when connecting to Git repositories using an SSH URI.
In cloud environments such as Cloud Foundry, the local filesystem may be ephemeral or not easily accessible. For cases such as these, SSH configuration can be set using
Java properties. In order to activate property based SSH configuration, the property `spring.cloud.config.server.git.ignoreLocalSshSettings` must be set to `true`.
Example:
[source,yaml]
----
spring:
cloud:
config:
server:
git:
uri: git@gitserver.com:team/repo1.git
ignoreLocalSshSettings: true
hostKey: someHostKey
hostKeyAlgorithm: ssh-rsa
privateKey: |
-----BEGIN RSA PRIVATE KEY-----
MIIEpgIBAAKCAQEAx4UbaDzY5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iGBjO6z
FwlJc/xlFqDusrcHL7abW5qq0L4v3R+FrJw3ZYufzLTVcKfdj6GelwJJO+8wBm+R
gTKYJItEhT48duLIfTDyIpHGVm9+I1MGhh5zKuCqIhxIYr9jHloBB7kRm0rPvYY4
VAykcNgyDvtAVODP+4m6JvhjAoGBALbtTqErKN47V0+JJpapLnF0KxGrqeGIjIRV
cYA6V4WYGr7NeIfesecfOC356PyhgPfpcVyEztwlvwTKb3RzIT1TZN8fH4YBr6Ee
KTbTjefRFhVUjQqnucAvfGi29f+9oE3Ei9f7wA+H35ocF6JvTYUsHNMIO/3gZ38N
CPjyCMa9AoGBAMhsITNe3QcbsXAbdUR00dDsIFVROzyFJ2m40i4KCRM35bC/BIBs
q0TY3we+ERB40U8Z2BvU61QuwaunJ2+uGadHo58VSVdggqAo0BSkH58innKKt96J
69pcVH/4rmLbXdcmNYGm6iu+MlPQk4BUZknHSmVHIFdJ0EPupVaQ8RHT
-----END RSA PRIVATE KEY-----
----
.SSH Configuration properties
|===
|Property Name |Remarks
|*ignoreLocalSshSettings*
|If true, use property based SSH config instead of file based
|*privateKey*
|Valid SSH private key. Must be set if `ignoreLocalSshSettings` is true and Git URI is SSH format
|*hostKey*
|Valid SSH host key. Must be set if `hostKeyAlgorithm` is also set
|*hostKeyAlgorithm*
|One of `ssh-dss, ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 ,ecdsa-sha2-nistp521`. Must be set if `hostKey` is also set
|*strictHostKeyChecking*
|`true` or `false`. If false, ignore errors with host key
|===
===== Placeholders in Git Search Paths