How to clone a git repository using SmartGit as ssh client on Linux? - linux

Unable to find clear instructions, and other questions have Windows answers.
Under hosting provider I have toggled 'Use SSH instead of HTTPS to access repositories':
gitlab smartgit
And I have configured smartgit as SSH client:
smartgit ssh client
I have my ssh key in the right folder: /home/user/.ssh/id_rsa_4096_gitlab
When cloning smartgit still asks me for http authentication. So my questions are:
How can I clone a private repository using SmartGit as a SSH client on linux?
At what point is smartgit going to ask me what ssh key to use?
Or what name should I give my ssh key so smartgit recognizes it?

I forgot that I had to add the ssh:// version of the url, once I did, smartgit asked me for the SSH key location and everything works now.

Related

Git not storing credentials when sshed into server

I have a ubuntu VM which I SSH into from a windows machine to develop on. I have my windows pub key on the linux VM so I can ssh without password.
On the linux machine I have set to store my git credentials. When I do any git command on the VM directly, it is able to use the stored credentials and carries out the given task. However, if I ssh into the VM from windows, and try to do any git command, it never stores the credentials and each time I have to reenter the password.
What is causing this and is there a way to fix it?
Compare the output of git config --show-scope --show-origin credential.helper when:
you are logged in directly on the Linux server
you are logged in through SSH from Windows
This assumes that, in both instances, you are using an HTTPS URL from your Linux server when using git clone/push/pull to a remote server.
If the Git on Linux is not recent enough, use simply git config --global credential.helper.

GitLab Subdomain, Cloning via HTTPS Does Work. Cloning via SSH Does Not Work

I started to work for a new client and they have a GitLab subdomain to keep all their repositories. I applied my ssh key and gpg2 keys to their GitLab account. However, when I try to clone via ssh, I time out. But if I were to clone via HTTPS, everything works fine.
What step am I missing to get the ssh portion working?
Cloning via https does work.
https://gitlab.company_sub_domain.com/company/repository.git
Cloning via ssh does not work.
git#gitlab.company_sub_domain.com:company/repository.git
config file:
In case this may be of any help:
Try completing your ssh config file with
Host companysub
Hostname gitlab.company_sub_domain.com
User git
IdentityFile ~/.ssh/id_ed25519
(put the "Preferredauthentication publickey" part in Host *)
That way, your URL would become companysub, as in:
git clone companysub:company/repository.git
First, try an ssh -Tv companysub, to check if the key is recognized and working.

Configure ssh private key in smartgit

I'm trying to configure a git repo in SmartGit through a SSH tunnel on Ubuntu 16.04.
I can't configure my private SSH key in SmartGit. I want to use the SmartGit SSH client but the Pereferences->Authentication don't allow me to add a key to use.
When I pull from the remote, I get a 'permission denied' error.
I found windows related topics but nothing on Linux distribs and nothing in SG documentation.
First, make sure to configure the System SSH client in the SmartGit preferences.
If you have ssh in your path, you can then export the GIT_SSH_COMMAND environment variable to instruct Git to use the ssh :command of your choice.
In your case, a command which would directly reference your private key
export GIT_SSH_COMMAND='ssh -i /path/to/private/key'
Then launch again SmartGit (for it to inherit that new environment variable), and try again your SSH tunnel.

How do I use the right key for SSH, connecting from Git Bash on Windows to remote server?

I'm trying to push my project on git to my remote Linux server from my local Windows PC.
I have no issues connecting to my server through SSH when I use PuTTY. But PuTTY is only for the remote server, and doesn't let me look in my own local pc - so I can't access my git repository to push from.
Instead I've been trying with Git Bash, where I go to the repository(master) of my git project, and then attempt "git push production master". Receiving "Permission denied (publickey)" in response in Git Bash.
I have loaded by private key from my user/.ssh folder on local pc, using PuTTYgen, copy/pasted the public key it shows into my Github account's SSH-keys.
This is the same key that I use for connecting with PuTTY(which works).
If I use "git remote -v" in Git Bash, I receive what is the correct url for the server:
"
production ssh://notacop#mafiauniversedata.com/var/repo/site.git (fetch)
production ssh://notacop#mafiauniversedata.com/var/repo/site.git (push)
"
"notacop" is the admin user I made instead of root, which is also the one that I use in PuTTY.
If I attempt "ssh notacop#mafiauniversedata.com" in Git Bash I also receive the "Permission denied (publickey)" response. So seemingly the issue is related to the publickey that Git Bash uses, as it can't connect at all.
My user/.ssh folder contains:
digitalocean_private_key (is the one PuTTY uses/the one generated by PuTTYgen) + digitalocean_public_key
github_rsa + github_rsa.pub
id_rsa + id_rsa.pub
known_hosts
I feel like I've set things up in accordance with the general guidelines, and it does work in PuTTY, so the issue must be related to Git Bash and how Git Bash establishes ssh connection.
But I'm fairly clueless about how to fix the issue, and haven't been able to find a solution from searching. My guess is that it's something fairly simple, but I've been stuck on this for a couple weeks now, not getting anywhere because of it.
Any answers that can lead me in the right direction will be highly appreciated!
If anything about my question is unclear, or you need more information to answer, please let me know.
I don't know why Git Bash's own ssh doesn't seem to work for you,
but I have a better recommendation: make Git Bash use PuTTY, by setting the GIT_SSH environment variable to the path of plink.exe (that's not a typo, it's not putty.exe, but another executable that comes with the zip of PuTTY tools).
The main advantage and reason to do this is so that Git Bash can benefit from pagent.exe, the key manager of PuTTY.
So that you can enter your passphrase once,
when adding your private key to Pagent,
and then you don't need to re-enter it every time you perform remote operations in Git Bash.

Subversion svn+ssh access and prohibit copying files from server via SSH

System environment :
Server: Centos 6.2
Client: Windows + TortoiseSVN + putty
I have installed subversion in centos, created repository on server, and configured svn+ssh access way using key authentication. Everything works fine.
But I have a question about svn user using svn+ssh mode.
The svn user have a ssh key, so he can access subversion server and of course he can also access Centos server by SSH using the key authentication. Further, he can copy subversion repository files(Specifically /db files) from centos server using like WinSCP tool base on SSH.
So, I wanna know if there is a way that let the svn user just can access svn repository via svn+ssh and can't copy repository files from centos directly via ssh accessing?
If he can copy repository files from centos server via ssh, I think the svn access control realized by conf/authz file doesn't make any sense and svn repository isn't safe.
I just learn how to create a svn+ssh subversion server, so maybe my knowledge isn't enough, please give me a idea or just tell me whether a solution exists.
If can't prohibit copying files from Linux server via SSH, I will use svn or http(s) access mode.
Thank you!
I found a way to solve this problem.
add command into authorized_keys file to disable ssh shell login and scp, but enable svn+ssh, like this:
"/usr/bin/svnserve -t -r /svn/test/",no-port-forwarding,no-pty,no-agent-forwarding,no-X11-forwarding
after add your authorized_keys file will like this:
command="/usr/bin/svnserve -t -r /svn/test/",no-port-forwarding,no-pty,no-agent-forwarding,no-X11-forwarding ssh-rsa A......................................................................
I think this is one solution, do your have others? Please let me know.

Resources