使用Feign调用时添加验证信息token到请求头方式
538
2022-08-22
springcloud配置ssh的问题及解决方法
在gitee上创建springcloud仓库
application.yaml(https方式)
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务器的微服务名
cloud:
config:
server:
git:
strictHostKeyChecking: false
uri: https://gitee.com/su-qiqaq/spingcloud-config.git #github上面的git仓库名字
force-pull: true #设置强行pull拉取
#搜索目录
search-paths:
- springcloud-config
#读取分支
label: master
eureka:
client:
service-url:
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
application.yaml(ssh方式)
发现报错,原因是没有配置私钥在yaml中
com.jcraft.jsch.jschexception: reject hostkey:github.com
如果以前在gitee中配置了公钥,就可以在C:\Users\用户名\.ssh的id_rsa文件获取私钥,添加在yaml中
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务器的微服务名
cloud:
config:
server:
git:
uri: git@gitee.com:su-qiqaq/spingcloud-config.git
strictHostKeyChecking: false
privateKey: |
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAtBGJMiwsYbIH1ljXjp9kP8utlxIT85U7sGdQJFtxDpn7nUc5OvuO
9++JumUQNbKv5284GaYRGogRPvpfAupjq/vz4oolJHOwktELeioN+wIN0ZEhGKQlFF1UmW
NONZnsG0geBzieRJFMDvpA2IV0V1jP1C7+jFqLjWTXT2qLsXgwVCxAqyso3o9s4eVKSsEK
fJyHCUeoIqUgE30P0LYhd5ubvCUwO77DCDWb3b05VFDD9AKYlF9xXBTN++KHQWOKthtIjg
8ncuZPwrZWkZhinj39NMQJA+G1qN7ZP80OwTAHmJfaOXFHTWfIfdU4UuM/RKRm7hJlBLee
KJpuajHSQoU+I7yS7bXKMhZvOfhAiQscw0DbawFWe5Gaq+GeQs7QnBr3Au3/VGOF4G0ksf
b3Rcp/bLeCXsLnVXh/W2u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zqq/afFHeRk+Ib9m9xpcKWgHj/XXd+tvHg
E098I0gtn2jf4ivaCbux8pB9gS8f9QCbj6CQwuQuJwGkWk40Eu8iKPQ9QyqU6U8PNRAAAA
wQCVazzRZInKcVyAV+R4qU9RHOSn75Nvq3y/Ph4gxGDX98llTb3CQvjDgP4w2fbrgwPHwm
6GKKRtYxUXdTY4eZRGj5QCCz3uGe8dXh4G5HbRqL17hCfyaVoJblgfJrlY/I76DvbrEkOE
/CNxQuBYPpXClEe5LEguCWz07Y/yW4c3yAzAWQqsgtHiTh/Qs3qeFluJj++MbZ03cFTavo
UL0os7jijvzcoiWG4sDDf1tucL9MhY3rCy9vqQWqoJH1+dA/gAAADBANoHeMvW/KTrs5hw
UIPDo0lEH+P2GCdeaPLeHeuyM5V+17+d6vqVYadw82yhMOcpM3wr5oFhZpm/36YKt1HbqF
z4X+aqMC855W4VnCQDs1OvJU6wt42iYMCctN7lfbx2CCzoMaA8/2v8239z85O1LeM0h3K0
djn/idD3DITYKvBuoxOF3BZ1W2U/0b+DUWhH/yrrHpXsmjyqtWgwZLBKzUzXJj/T32pwDM
Pko4S9P4SANE/Vk4Uj5s02DwgtI7Im2wAAAMEA022jvQIP8mLkFD7KTdnBwb4HS2hp5e9t
P4NTtrXtZE+POjZ54TPerNUxh8ymf766EGeA/ImgPhNWSFKriWC4aFp2UKflPs7/0+jFfB
yNjqVEUH410HCuip+yNUcEW3HN/N8UR/l48WDTXh8mdL4vGxtpTiHii4hPB1zyw1Ku3JA+
gDKVBN1pQ2I3Ldxe1n4HYB66PJpWsFZ41JDPiMSmhWwMreUrv0niowqUKttidg+9yEiRB4
5ToAmFqEFbswhFAAAAETExNDE3OTM5NjFAcXEuY29tAQ==
-----END OPENSSH PRIVATE KEY-----
# uri: https://gitee.cohttp://m/su-qiqaq/spingcloud-config.git #GitHub上面的git仓库名字
force-pull: true #设置强行pull拉取
#搜索目录
search-paths:
- springcloud-config
#读取分支
label: master
eureka:
client:
service-url:
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
出现错误
Auth fail
原因:
仔细查看后发现我的私钥是以BEGIN OPENSSH PRIVATE KEY开头,END OPENSSH PRIVATE KEY结尾,而
现在服务端如mysql,gitee等还不支持这种格式,因此我们还是生成原来的格式:以BEGIN RSA PRIVATE KEY开头,
END RSA PRIVATE KEY结尾。
解决:进入 git bash重新生成私钥和公钥:
ssh-keygen -m PEM -t rsa -b 4096 -C "1141793961@qqyHONm.com"
同样,重新在C:\Users\用户名\.ssh的id_rsa文件获取私钥,添加在yaml中,并且
重新在C:\Users\用户名\.ssh的id_rsa.pub文件获取公钥,添加在gitee的ssh公钥中
server:
port: 3344
spring:
application:
name: cloud-config-center #注册进Eureka服务器的微服务名
cloud:
config:
server:
git:
uri: git@gitee.com:su-qiqaq/spingcloud-config.git
ignoreLocalSshSettings: true
strictHostKeyChecking: false
privateKey: |
-----BEGIN RSA PRIVATE KEY-----
MIIJJwIBAAKCAgEAqEh1DblLHWCzmrQpbevjWwQihOufLgglt2Lv0uT76BnOI+gi
8YzQjgNSOPDSN6gjwiBayLqkD/cAJZeCOMj5PJyZIs9HXs/V9vUHoZRtYR7z+k0+
QZLJDtJWB9QNCoEwbpzMCwNisuKCW3tktvTVtV9Yq1+EB6RvseRWZbf1wJbVv16T
R0u9oYq1eaVflH0nuT/CJSi/uGO81rglGirgqwwOJSmz8MxDxp24HMuQRDK+xtXe
8pBmvtEKirnWcB0NBWmQDd5OljpFhrLBT71YMHKvFvBtcMfpgfgdvrkvZcqlhTiO
tAAYnsannHDF+y1L2pa76gFmPgi0HNIj4PfHc29H9d1XdH/0vzeMr6KeMhiwRBO9
pUYcILI2/+Q5774+Be398tSx6czJoNbrzvTj1OzvYZ8Qu80LRPWlNBfzuRTF2tLv
ummsnisrY0ii/i7FYL5RdheLvGov3qTudNRPwvFUvXG/fqFrq0QZMr9RahO8JPo0
lViwCYc5oOLVr4xrajqz4pKXacfj7Q4M5W6lAUgDTFmNs7OhN1g9Rue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dPF0Z2s0maALh1WJiTUvPyZ
WLMOuqZPLEUyU6rJQcbhKmo0VdwKm74wi1zTLslIwjg7IIWrSTNhvgTEW45pfm/v
YhCo10Vd9XLNt6Acszk1imhQ8eUKacECggEAB/ZcUrw0/RvDzYWB+e/L0dFuIFuG
oPAm23/UayIENEniIgSeEPR2XnfJQLEjLu9RMEZ5Wn9FWICjqhZJVpNwVhPDFCEZ
zW2On5U50EtmHTLZ7KxgR4w9YR9uqaB9cuOXTU1imO7Cs6envJ0iO6pWEFQa531Y
XafOgOoIlZ54N/qJhS6PcYBwmgtKCl2v9PzxOJSdQRxQriTW+/EtFeqXhjcdQw4K
UtbkGcqbg0woJkis0XnDt5tCddmATvtdngzb+9Rn+3B0i1r2ksU5/SaU1wdEmBmb
WAsX8ey+pGxKaMPm+88FeE8yHONmglVcJ6BxFTmvng1PImOazvvZAAhvhObZO4A==
-----END RSA PRIVATE KEY-----
# uri: https://gitee.com/su-qiqaq/spingcloud-config.git #GitHub上面的git仓库名字
force-pull: true #设置强行pull拉取
#搜索目录
search-paths:
- springcloud-config
#读取分支
label: master
eureka:
client:
service-url:
defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/
参考文章:
https://blog.csdn.net/u011863024/article/details/114298282
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~