Unable to use key file Eclipse - eclipse

I setup public key access to my server via ssh. I have a .ssh folder on my local windows computer. I configured ssh to add the private key using the ssh-add <directory> command. I am able to successfully connect to my server using windowspowershell. The chmod and Chown of the .ssh directory and authorized file are configured correctly on my server. sshd_config is configured correctly and points to the correct key.
The connection works perfectly with shell so there is no problem on my server. But with Eclipse, and its plugin in particular, Egit, I keep getting a Unable to use key file <directory of the key file I loaded into eclipse the same one used by ssh error every time I try to push my revision commits to my git repository on the server. I went to Pref > General > Network > SSH2 and added the right private key, the ssh2 home directory is set correctly too, in fact the public an private key were both generated using the key management tab and loaded into my server.
My windows permissions on that folder and those keys is set to allow all users to do everything just for good measure.
Now one clue is, the known hosts tab has a host fingerprint that does not match the fingerprint of my key. My key is something like f1:19: etc and the hosts fingerprint is different. I hope I can fix this soon. Any suggestions would be great.
ssh-add -l = two private keys that I am using. So its not this.
Another clue is, after going into my putty program and changes the private key that it ses suddenly is i try to connect to ssh with a key acces in eclipse the error it throws shows reflects the same key that I just changed in putty!! Somehow eclipse seems to be using putty for public key access. How do I stop this?!

Okay here's the solution. For whatever reason Egit uses putty to connect to ssh using the configuration putty is set to use to access a server with a public key. The way you fix this is to make sure putty is able to connect to the server using a public key. If it can't then try this:
Download puttygen
Generate a rsa key using either ssh shell or the key management tab on eclipse. Do not generate a key using puttygen. For whatever reason it never worked for me.
Load the private key you generated (not generated with puttygen) into puttygen and then save as a putty private key (.ppk)
Go to eclipses key management tab and set it to recognize the new .ppk private key file
Finally go to putty, and create your servers profile by assigning the address and then go to auth and load the .ppk file. DISABLE pageant.
Save and attempt to connect to server using the key and if successful then congratulations Egit and Eclipse will now be able to make connections using keys.

Related

GitHub SSH key on a USB drive

I'm curious if I can put a GitHub SSH key on a USB flash drive as a singular key and remove the other SSH keys from my GitHub. I've found one source, but it doesn't necessarily specify that it's for GH, here.
Any help is appreciated, thanks!
I have yet to experiment, just reading articles/watching YouTube videos to try and get a grasp on it.
As long as you are using a ~/.ssh/config file which points where your SSH key is, you can put said key pair wherever you want.
Host gh
Hostname github.com
User git
IdentityFile /mnt/usb-device/myKey
In your case, a nix copy --to file:///mnt/usb-device /path/to/key would be needed first.
However, the tutorial you are referring to is more about copying the key on an encrypted USB stick. Which might be a bit redundant, considering NixOS can be installed with Full Disk Encryption already.

How to encrypt files in Heroku?

I would like to find a way to store encrypted file in my github repository that Heroku can decrypt on-the-fly (it's not env var but plain old .csv files).
I used git-crypt successfully on my machine but it seems that I cannot add a gpg key to heroku.
When I connect to heroku-cli and I try to create a gpg key usingheroku run gpg --gen-key I got the following error:
gpg: signing failed: Inappropriate ioctl for device
Anyhow, I'm not even sure git-crypt is the right way to go, so feel free to gave me any other alternative solution.

Use built-in SSH in Oracle SQL Developer instead of using PuTTY first

I don't have extensive knowledges about Oracle SQL Developer (Version 17.2) and SSH tunnel. I have been using PuTTY (KiTTY is the software I used) to establish SSH tunnel to connect to the database. This is the example of how I set up originally with KiTTY. Also, when I start the session where a command prompt window will pop up, I'll need to enter username and password. Let's assume the Username is username and the Password is password. And for the database, the Username is database_username and the Password is database_password.
SSH Setup:
Tunnel Setup:
I learned that you can use SSH (View > SSH) function directly from Oracle SQL Developer, and I have tried for two days but didn't work. From the information I have attached in the two pics above, will I be able to use the built-in SSH function or do I have to always use PuTTY? This is how I set up currently:
SSH in Oracle SQL Developer Setup:
How should I change the built-in SSH setup in order for me to connect to database through SSH? Will this be possible? If so, can you show me exactly what I need to enter the information into those fields (please use mine so I can follow each step)? I just think this process can be simplified within one program.
I finally found the answer for myself after two days of searching and a coworker's advice. Here is what you do to use built-in SSH function in Oracle SQL Developer that also requires SSH Tunnel. And no more PuTTY is needed for this process.
SSH Setup:
As shown in the pic below, this is what you need to enter. Please note there are two Name's fields. You can make up any name you like to use. Don't forget to perform a Test run to ensure this works. To Test run, go to SSH Hosts window, right click on the SSH connection and select Test.
Now the tricky part is here. You should see there is a Connections window on the upper left corner. Click the green plus icon button to add a New Connection.
Database Connection Setup:
Fill out the info as you can see the pic below for example. The key is to change the Connection Type to SSH, Port Forward should also point to the SSH connection that you setup above, and you should have a Service name provided by your DBA team. Once this is set, you can perform a quick Test run and see if everything is working.
The good thing about this setup is that you don't need to run PuTTY on the side. You can simply click the database name and it will prompt you the password and that is it.
P.S. I heard there is a way to store the password using SSH key but I am not familiar with the process and still trying to figure that out. Maybe post your steps here and I will definitely upvote for you.

unable to get SSH keys working between sourcetree and github

I was able to create a key and connect to github following these instructions via the command prompt successfully:
https://help.github.com/articles/generating-ssh-keys
However, when I try to connect via Sourcetree and putty I cannot. I've tried:
generating a new key with the putty key generator (SSH-2 RSA)
entering a passphrase
saving the private key
saving the public key and adding a .pub extension
copying/pasting the key from the putty key generator window into github
attemping to refresh branches on a pull from my private github repository from my local repo using the SSH clone URL I got from github
I also tried opening the key generated from the github command line instructions and it wanted me to convert it to a putty-type key which I did and saved off, tried with that one. Also no luck.
What am I doing wrong?
In order to get it worked I ended up going to Tools -> Options -> SSH Client and changing it to OpenSSH. I generated and uploaded several different types of keys trying to get it work as well but I think this is what finally did it.
In my case, I needed to switch to a git or ssh based repo path rather than the https based repo path. This causes SourceTree to switch to SSH based authentication.
This setting can be found at Repository => Repository setting => Paths
Example:
Correct repo paths
git#github.com:<username>/<reponame>.git
or
ssh://git#github.com/<username>/<reponame>.git
(Note: if you are working with a repo that isn't yours, replace username with organization name)
Wrong repo path
https://github.com/<username>/<reponame>.git
HTTPS repo paths result in SourceTree trying to be extra smart and failing spectacularly. You get prompted for a username/password GUI dialog which will never work if you have 2 factor authentication enabled.
To login to Github account using SourceTree you may use access tokens. To create an access token follow these steps.
Go to Settings
Select Developer settings from left pane
Select Personal access token
Click on Generate new token button
Give it a name
Select scopes and generate token (save this token somewhere safe because you won't be able to access this token again)
Then in SourceTree app follow these steps (for Mac users, not sure about the other platforms)
Go to Preferences->Accounts
Click add button
Select GitHub from Host dropdown
Choose Basic from Auth Type dropdown and HTTPS from Protocol dropdown
Enter your GitHub username in Username field
Paste the access token generated in the previous process in the Password field
Click save and you're done
For Mac versions of SourceTree the Tools menu does not exist.
However, you can add the ssh key to your keychain in Mac OS. See: https://superuser.com/questions/879050/sourcetree-ssh-options-on-os-x
On Mac OSX, the native SSH client can use the built-in keychain directly. To add your private key to the keychain simply use the command:
ssh-add -K /path/of/private/key
As an example if your private key is stored at ~/.ssh and is named id_rsa, you would use the command:
ssh-add -K ~/.ssh/id_rsa
You will then be prompted for your passcode, which will be stored in your keychain. After this you should be ready for a password-less login.
You may want to consider switching from OpenSSH to Putty / Plink and use embedded Git instead of Git provided by host OS. Making ssh-agent work on Windows is a bit more complicated than clicking it out straight from the SourceTree and PuttyGen.
If you want to still use terminal to configure SSH and start ssh-agent please see bottom two steps.
For Sourcetree on MacOS I had to change from OAuth to Basic authentication, use "git" as the username (not my GitHub username), and generate the SSH key and input it into GitHub. Only then could I clone a GitHub repo via SSH in Sourcetree.

how can i connect GitHub through putty

I had follow the steps given in so many docs like this one,
after creating a key i pasted it in my GITHUB account>account settings>SSH key.
When I add it there it shows a message:" key is invalid".
I really don't link the tutorial part which mentions:
Save the private key somewhere with a passphrase and then copy the public key text to the clipboard.
"somewhere"? ssh keys must be saved in %HOME%\.ssh.
(Note: %HOME% doesn't exists in windows, and default to %USERPROFILE%)
Make sure to have your public and private keys saves in:
%USERPROFILE%\.ssh\id_rsa
%USERPROFILE%\.ssh\id_rsa.pub
set HOME=%USERPROFILE%
plink git#github.com