spring cloud config 读取ssh协议的git

spring cloud config 读取ssh协议的git

摘要

spring cloud config 读取ssh协议的git

spring cloud config

spring cloud config可以把所有配置外部化,集中存储在git中.
git访问协议使用ssh

server:
  port: 8040
spring:
  application:
    name: configserver
  cloud:
    config:
      server:
        git:
          uri: "git@xxxx:zhushaolong/gitconfig.git"     # 配置git仓库的地址
          search-paths: config-repo                             # git仓库地址下的相对地址,可以配置多个,用,分割。
#          username:                                             # git仓库的账号
#          password:                                  # git仓库的密码

https可以使用,ssh不能访问

ssh协议下springboot访问gitlab报错

Spring Boot Config Server git@xxx.git:UnknownHostKey: gitlab

先在本地修改 ~/.ssh/config

Host xxxx
    User zhushaolong
    IdentityFile ~/.ssh/id_rsa
    HashKnownHosts no
    HostKeyAlgorithms ssh-rsa,ssh-dss

再 ssh xxxx 连接一次gitlab所在的服务.为了生成known_hosts

或者不校验

Host xxxx
    User zhushaolong
    IdentityFile ~/.ssh/id_rsa
    StrictHostKeyChecking no