Spring Cloud Config using Bitbucket - SSH keys - spring

I'm facing an error when I try to authenticate in Bitbucket using SSH private key to get my application.properties.
org.eclipse.jgit.api.errors.TransportException: https://companyuser#bitbucket.org/repositorios/cup-configuration-files: not authorized
Steps:
1) I've generated the key pair using ssh-keygen with a password
~/Development/ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ainacio/.ssh/id_rsa):
2) I've copied the key.pub to Bitbucket
Bitbucket - User - Personal Settings - Add key
3) I've configured in bootstrap.properties the private key
spring.cloud.config.server.git.uri=https://companyuser#bitbucket.org/repositorios/cup-configuration-files
spring.cloud.config.server.git.ignoreLocalSshSettings=true
spring.cloud.config.server.git.passphrase=password
spring.cloud.config.server.git.privateKey=-----BEGIN OPENSSH PRIVATE KEY-----\n
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABD4Kfq1XF
NpUPV+q/U7OPwhAAAAEAAAAAEAAAGXAAAAB3NzaC1yc2EAAAADAQABAAABgQDuPOdeTNts
gLWlN7hLM7h+R9W76HjzrJ6pNHFVq8htKaQodmGuNFrna1y6k88FMds4XAJIv8rB2C2TyD
Y+eVKsKCfQ7xSoP/3NwOegRmvVYVUETvDJrop2Cmi4DnM6QlrtDum+VicEKjtQD7sOJ85R
WJpHkf/+CIZW8cbwdaMAjtr9LE6t+4lOg15Xfyu9zFI4YBpxb3C08/x4CS0bdiWX73Z+uT
AQWfGSbcxXleFHCDv0xCvE6/uMt2rTsnuFfLNTannEwzIYLV//0eMesQywzN+D3gxPZKeG
P1E54xXVjewsW74GJhmnI5Tm5DvsXvvQ5bkELH+isPrH9sZbncPFq9e6qjA88gk2BCLEe/
E5jdL0OKrIGFJjwpN8T/sDfq3SvuLIPvOsLlZXw0yUDgTvJdLKdwSFFB7WPKZqINXBSmKr
PUKZMm3WBB4gLccU+vD/1uardrMZ5lj0hJp7YRukWfXCFvZYLs0lnM2xnTuFsKNOfxOKDv
....
What is missing? I tried to find some tutorials but I couldn't.
PS: I'm in development environment. Accptance and production I'll use the file on .ssh server directory.

It needs to use RSA encryption algorithm ssh-keygen -m PEM -t rsa -b 4096 -C 'bitbucket_username'

Related

SSH Permission Denied and Different Fingerprint Generated in Terminal compared to in Gitlab SSH Key

Currently I am facing a problem with git clone a repo using SSH. I had set up my SSH Key and inserted it into GitLab. However still it does not work out.
Permission denied as like below:
And another problem is the fingerprint generated above is different from the one that is generated in Gitlab as shown below:
Hope if anyone could help. Had been troubleshooting this for a few days.
I tried to delete the .ssh folder and regenerate new key and did everything the same again but turn out to be the same, Permission denied and fingerprint is never matching.
I am using OpenSSH and OS: Windows 11 for this problem. I had also tried ssh -Tvvv <username#server> , ssh <username#server>, ssh -Tv <username#server> to verify whether if I am connected but the same permission denied.
As commented, the server fingerprint (for the ~/.ssh/known_hosts) differs from the public key fingerprint.
For the latter, test it with ssh -Tv git#gitlab.com, and check your private key is used.
If your private key does not have a default name (like id_rsa), you would need a ~/.ssh/config to reference your key.
Host gl
Hostname gitlab.com
User git
IdentityFile ~/.ssh/myKey
And ssh -Tv gl for testing.

How to use svn+ssh in IntelliJ Windows?

Our SVN server allows ssh connections only. How can I configure IntelliJ on Windows to connect to SVN server using svn+ssh?
In order to connect to SVN using ssh on a Windows machine, you will need to
Generate your ssh private key and upload it to your user allowed keys on the server.
Create a saved PuTTy session to use the private key file.
Download TortoiseSVN Plink to be used as SSH tunnel.
Configure IntelliJ to use TortoiseSVN to connect to your SVN server.
Here are the details of these steps.
1. Generate your private key.
You can use PUTTYGEN to generate the private key.
Then save the key in the .ssh folder in the user home directory.
If you have Windows 10, you can use Bash on Ubuntu on Windows to generate and load your private keys.
ssh-keygen -t rsa
This will generate the file ~/.ssh/id_rsa
Then load the key to the server
ssh-copy-id amr#example.com
The final step is to move the generated file from the Ubuntu subsystem path to your home directory in windows.
cp ~/.ssh/id_rsa /mnt/c/Users/amr/.ssh/
You still need to convert the key from OpenSSH to PPK format using the PUTTYGEN tool. From the tool load the file and then save the private key again in the PPK format.
2. Create a saved PuTTy session and configure it to use your private key.
Create a new session in PuTTY for login into the SVN server and change the setting of SSH/Auth to point to the private key file
3. Use Tortoise SVN Plink as the ssh tunnel
Download and install Tortoise SVN. It has a command line tool named TortoisePlink which is based on puTTY. We will use plink as the SSH tunnel for SVN.
4. Configure IntelliJ to use this SSH tunnel for Subversion.
Go to File/Settings/Version Control/Subversion then select SSH settings tab.
Select Subversion config
make sure SSH tunnel is set to $SVN_SSH ssh -q
then add the path to TortoisPlink as in the picture. Make sure to skip backslashes.
Then, you are good to go.

Public key issue with command line in sourceTree (git )

I usually use git on linux and I'm not familiar with sourceTree on windows ( c# project ), the interface is usefull to follow the tree, but I would like to the use commande line .
I really don't understand, I generated my ssh key with sourceTree agent and load with "Pageant", I added the public key on my bitbucket account.
And it works. I can clone/pull/push from the sourceTree interface
But using the sourceTree command line mode doesn't work
Set SSH Key to a PuTTY private key (.ppk) and set SSH Client to PuTTY / Plink
Set an environment variable GIT_SSH to the path of plink.exe, for example C:\Program Files (x86)\Atlassian\SourceTree\tools\putty\plink.exe
Of course you could have a separate, global OpenSSH key in %HOMEPATH%\.ssh\id_rsa but then you would lose the advantage of SourceTree loading the correct key automatically.
By the way, I can confirm that neither of these work:
Setting SSH Key to an OpenSSH private key and using OpenSSH as SSH Client
Setting SSH Key to a PuTTY private key and using PuTTY / Plink as SSH Client
Nothing of the above was necessary to make it work for me. The only necessary aspect to consider is that by default git (and maybe other apps) expect your ssh key in c:/users/<user>/.ssh. Mind the dot! After I renamed my ssh folder to .ssh all started working fine.
you need to generate public key from console.
like this
ssh-keygen
it will generate public key that you can add it in Bitbucket
for more info visit this Tutorial

SHA Key with Windows and MsysGit/Free CopSSH

OS (for better or worse) is XP
I am having some issues, I have seen other questions but none seem to apply to me.
I have CopSSH installed and I can log in using cleartext password.
Now I want to upgrade that to SHA keys.
I use PuttyGen to get a public and private key
I then copy those into ~/.ssh and %ICW%/home/%un%/.ssh as id_rsa and id_rsa.pub.
I add the public key as follows....
Example Pubkey
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20121115"
AAAAB3NzaC1yc2EAAAABJQAAAIBdfRGHY4IYsUuDYzbgEy1wKXrszq5RVR4m2/gP
WJwLwiaNHpahfPeHmsG7nD7qeVNVp+sSVouApm70ZdfGnxzOHiBydtdOuco+sbqZ
irlyG9wS5yv8x9LFsGqZ34tbr8dgPXMdYnrJHJqUa3+ZMUNPXznRUzj/VTiwoS6/
jMHzkw==
---- END SSH2 PUBLIC KEY ----
Example known_host
<ServerName>,<IP>,localhost ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBdfRGHY4IYsUuDYzbgEy1wKXrszq5RVR4m2/gPWJwLwiaNHpahfPeHmsG7nD7qeVNVp+sSVouApm70ZdfGnxzOHiBydtdOuco+sbqZirlyG9wS5yv8x9LFsGqZ34tbr8dgPXMdYnrJHJqUa3+ZMUNPXznRUzj/VTiwoS6/jMHzkw== UN#SERVER
So now I add the generated private key to putty and try to connect but I see the following...
Server refused our key
It still allows me to log in using my password.
How can I get the Private Key auth to work?
Check if Itefix FAQ https://www.itefix.no/i2/content/i-want-use-my-own-pka-key-pair-instead-one-generated-copssh can be helpful.

heroku complaining about my public key created by ssh-keygen2

I am trying to access my heroku app from work (windows machine).
I installed cygwin on the machine and generated ssh-key as well. However, I get the below error:
C:>heroku keys:add
"C:\cygwin\home\4541450\mycoolemail#email.com"
Uploading ssh public key
C:\cygwin\home\4541450\mycoolemail#email.com
Enter your Heroku credentials. Email:
mycoolemail#email.com Password:
Uploading ssh public key
C:\cygwin\home\c54550\mycoolemail#email.com
! Contents Invalid public key /
Contents Invalid public key /
Fingerprint can 't be blank
I generated the ssh key with the command below.
ssh-keygen2 "mycoolemail#email.com" -t
rsa
ssh-keygen is not available with this cygwin.
the "C:\cygwin\home\4541450\mycoolemail#email.com" should be your public key, not the private one
Perhaps my other answer here is helpful. It's my setup for deploying to Heroku from Windows.
Do you have a passphrase on the key? Mine didn't work until I generated one with a passphrase.

Resources