Spring Cloud Config - Cannot clone or checkout repository: ssh://git#github.com/<user>/repo.git - spring-cloud-config

When I try the URL with https it works but I don't want to have the username and password. I am able to perform a git clone with the above url and its working. But when I try it in the code and hit the localhost:8888/default endpoint I get the error:
{
"error": "Not Found",
"message": "Cannot clone or checkout repository: ssh://git#github.com/<user>/config-repo.git",
"path": "/licensingservice/default",
"status": 404,
"timestamp": "2018-04-30T23:32:54.726+0000"
}
Here is my application.yml entry
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: ssh://git#github.com/<user>/config-repo.git
searchPaths: licensingservice
I am using spring cloud config - Finchley.Not. No sure what I am missing. Please suggest.

Few things to inspect:
Do you have github in your known_hosts? If not, then it will prompt you to enter password even you have key pairs that might cause the error.
Do you have SSH keys under /home/{you}/.ssh/ folder?
When you generate your keys, did you use passphrase? If so, you need to include the passphrase key in your YAML file.
If all above are okay. Then download the spring-cloud-config-server, debug the org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.class
Good luck.

You have to add your machine's ssh key to the repo.
Ssh key should be generate with the following command:
ssh-keygen -m PEM -t rsa -b 4096 -C "your_email#example.com"
For more info, you can check this link
https://skryvets.com/blog/2019/05/27/solved-issue-spring-cloud-config-server-private-ssh-key/

I also faced a similar problem with spring cloud config server. You need to add an additional property spring.cloud.config.server.git.skip-ssl-validation=true in application.properties file.

Related

How to send Public Key while running ansible-playbook?

I am working on the vault-ssh secret engine method which is using the authorized CA for signing the keys and you can authenticate to the client with that signed certificate,
You can check this link:- https://www.vaultproject.io/docs/secrets/ssh/signed-ssh-certificates
I am able to log in to the client machine using the command:-
ssh -i id_rsa -i signed-vault.crt test#client-ip
same thing I need to do with ansible, but I find that in ansible there is no way to send the public key on the go, or while running the ansible-playbook command, you can send private key using the --private-key option.
So need help is there any way by which we can send the public key on the go or any work-around on this.
if needed more clarity on the vault-ssh-setup you can check out this blog
https://brian-candler.medium.com/using-hashicorp-vault-as-an-ssh-certificate-authority-14d713673c9a
i am searching something on the google and find this github link :- https://gist.github.com/nehrman/3951a9f61083e462c60aeffcd942acb8
we can use the set_fact to get this thing done.
- set_fact:
ansible_ssh_private_key_file: "{{ r_tempfile.path }}/id_rsa"
- set_fact:
ansible_ssh_extra_args: "-i {{ r_tempfile.path }}/signed"
- set_fact:
ansible_user: ansible
Thanks to the nehrman for writing this.
https://github.com/nehrman

fatal: Authentication failed when trying to clone GitLab project even though "ssh -i" command prints "Welcome to GitLab, [username]"

I cannot clone the project although
ssh -T git#gitlab.com
shows what I want: Welcome to GitLab, #vagnerwentz!.
The error during cloning:
Cloning into 'jobfygo'...
Username for 'https://gitlab.com': vagnerwentz
Password for 'https://vagnerwentz#gitlab.com':
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/jobfy/backend/jobfygo.git/'
I resolved changing the SSH Key to RSA Key.
First, you are cloning with an HTTPS URL, which means all your SSH settings is for naught.
Second, regarding HTTPS, double-check if you have 2FA activated, because if you do, your password would actually be a PAT (Personal Access Token)
Third, if you do want to use SSH, then use the SSH URL:
git#gitlab.com:jobfy/backend/jobfygo.git
By default, such an url would use the default private SSH key ~/.ssh/id_rsa.
So if you have a key with another name, you would need to:
either rename it to id_rsa
specify it directly ssh -i /path/to/second/private/key
use a ~/.ssh/config file

Satis - error with ssh2.sftp protocol

I am trying to host private composer repository with satis (http://getcomposer.org/doc/articles/handling-private-packages-with-satis.md)
It works fine through http protocol.
I want to secure it with ssh connection as described in security section (http://getcomposer.org/doc/articles/handling-private-packages-with-satis.md#security)
But having errors when connecting with ssh2.sftp:// protocol.
Composer\Downloader\TransportException]
The "ssh2.sftp://192.168.10.30/packages.json" file could not be downloaded: Error starting up SSH connection(-43): Failed getting banner
failed to open stream: operation failed
I have already generated key pair
I added pub key to authorized_keys file on satis server.
I can connect with ssh to satis server without entering pass, so keys are working.
What i am missing or doing wrong?
UPDATE
Also i had installed ssh2 module extention. It appears on output of the command php -m | grep ssh2
Found solution myself:
I was using ssh key pair with password. Apparently ssh2.sftp do not like this. Generated new key pair without password.
Secondly need to use full path from root directory. For example:
ssh2.sftp://192.168.10.30/home/[username]/path/to/location/packages.json
source: http://us3.php.net/manual/en/function.ssh2-sftp.php#94651)

If I run 'git push' via ssh then it outputs 'Permission denied (publickey)'

I set ./git/config file like this.
[remote "origin"]
url = https://github.com/haradashinya/dotfiles.git
It's pushed my github's repository but it asks for my username and password. So, I set my url to ssh style, like this:
url = git#github.com:haradashinya/dotfiles.git
But it outputs an error message saying 'Permission denied (publickey)'.
Why this happened?
Even if you have defined ssh keys, you need to be sure HOME is defined (which isn't the case on Windows for instance, unless you are using a DOS session from git-cmd.bat shipped with msysgit): see "Trying to “install” github, .ssh dir not there".
In that same HOME directory, you could also record your https GitHub credential (username and password) if you still want to use the https address: see "change github account mac command line" for an example.
You need to add your SSH key to your github account here: https://github.com/settings/ssh
If you haven't generated an SSH key, or you don't know how to generate an SSH key, or you don't understand how to add it to your github account, github provides detailed instructions here: https://help.github.com/articles/generating-ssh-keys
I've followed with https://help.github.com/articles/error-permission-denied-publickey instructions.
And I resolved my problem by ssh-add 'my-id-rsa-path' command.
ssh-add ~/.ssh/id_rsa;
ssh -vT git#github.com #-> success!
Thanks for help!

Maven site deploy authentication error with scp

I get Auth fail error when running mvn -X site:deploy.
org.apache.maven.wagon.authentication.AuthenticationException: Cannot connect. Reason: Auth fail
It seems that the correct private key is used and I can scp files normally to the project site directory using scp on Ubuntu.
What can be causing this?
I found out that I forgot to specify the passphrase for my private key.