git-tf how do I avoid specify my credentials every checkin - tfs

My question is exactly the title.
Every time I run the command git-tf checkin in my command prompt when its connecting to TFS it asks for my username and password. How can I avoid this?
Either have it to log in with the current user or store the credentials somewhere in a configuration file.

By far the most secure way to do this is to simply not store a password and to instead use single sign-on via Kerberos or NTLM:
If you're on Windows and logged into a domain that has a trust relationship with your TFS server, then you should not need to specify a username and password.
If you're on Windows and have a "shadow account" setup, then you should not need to specify a username and password. This occurs when you don't have a domain trust relationship with the TFS server but you are logged in to your local machine with the same username and password as the account on your TFS server.
If you're on a Unix platform, you can get single sign-on using Kerberos. This is most likely the scenario when you have a ticket from your Active Directory server itself, eg kinit activedirectory.domain.name.
Similarly, if you're on Unix and have a Kerberos ticket to a KDC that has a trust relationship with the TFS server (almost certainly the Active Directory server itself) then you should not need to specify a username and password. git-tf will use your logged in credentials to authenticate.
If none of these applies, then you can store the username and password in the git configuration for your repository:
git config git-tf.server.username your-username
git config git-tf.server.password your-password
Note that your password will be stored in the git configuration file in plain text. Be sure to set the ACLs or file permissions as appropriate to discourage people from reading your password out of your configuration file. Or you can store just the username and you will need to type only your password each time.

You can prevent git from saving this to the project's .gitconfig by using the --global switch:
git config --global git-tf.server.username your-username
git config --global git-tf.server.password your-password
It will still be saved in plain text on your system (C:/Users/your-login/.gitconfig), but at least it won't be saved in a file that lives in the project.

Related

Fastlane setup - fatal: could not read Password for 'https://<org>#dev.azure.com': terminal prompts disabled

I am trying to setup Fastlane for iOS certificates and profile syncing in my MacBook. When I execute the command sudo fastlane match development --readonly, I get below error.
What is it actually? I guess that the terminal is blocking the prompt where I could enter the match password. I do not understand why I face this issue, also I have access to the repository.
Normally, the password would be cached in your Credential Storage (osxkeychain on Mac), but for your current user.
And you are executing that command as root.
Check:
if you have a credential helper set (with your account)
git config credential.helper
if your credentials are stored
git ls-remote https://...
# if a popup is displayed, enter your credentials there
if the same command would work if executed as you (instead of root)
I assume you have used ssh with the old macbook, are you trying now with https ?
Btw, it is not recommended to use the local fastlane, see Bundler.

Sourcetree cannot push to bitbucket repo due to authentication issue

This may seem like a bit of a rudimentary issue, but I cannot seem to push from Sourcetree (windows) to a bitbucket repo for which my user is the owner.
To clarify I can log in to the repo using my browser just fine but when I push to it from Sourcetree and I enter the same details into the prompt box it fails to authenticate. I have tried using the username and email, I've even changed the password of the account but still no joy.
I also created an app password and tried using that as the password with combinations of the username and email, but no joy.
the error I am getting is:
git -c diff.mnemonicprefix=false -c core.quotepath=false
--no-optional-locks -c credential.helper= -c credential.helper="C:/Users//AppData/Local/ATLASS~1/SOURCE~1/GIT_EX~1/GIT-CR~1.EXE"
push -v --tags origin master:master fatal: HttpRequestException
encountered. An error occurred while sending the request.
remote: Invalid username or password. If your organization manages
your account or you've enabled two-step verification, create an app
password to log in: https://confluence.atlassian.com/x/9DJmMQ fatal:
Authentication failed for
'https://#bitbucket.org//.git/'
Pushing to https://#bitbucket.org//.git Completed
with errors, see above.
Any advice would be greatly appreciated
Try to add a new SSH key via Sourcetree, seems like Sourcetree is not picking up your username and password when you are using HTTP/S authentication, it can be because:
You have not added your account info in git global
You have not properly assigned credentials
Using SSH is a far preferred way:
https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html#SetupanSSHkey-ssh3
I deleted:
C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree\passwd
C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree\accounts.json
Inspired by this article: https://community.atlassian.com/t5/Sourcetree-questions/Getting-quot-fatal-Authentication-failed-for-quot-error/qaq-p/624663
It worked. When I restarted SourceTree it acted like it was the first time it was opened (downloaded some tools, asked me for my credentials). Once it finished, my project tabs were there, and I was able to pull/push.
Perform below steps:
Reset your password : https://id.atlassian.com/manage/change-password
Run below command from working copy
git remote set-url origin Your-repository-url-here
In order to get it worked I ended up going to Tools -> Options -> SSH Client configuration and changing it to OpenSSH. and set the path to the already generated ssh key file like C:\Users<user>.ssh\id_rsa.

Bitbucket/Github: permission denied public key

when I am trying to clone a rails app repo I have got permission to, I am getting this issue.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Even after adding public key by generating one, I am unable to solve this.
Although I am able to clone using he https method but after making changes, the same error comes while I try to push the code.
Please suggest an answer for this.
First, cd into your .ssh directory. Open up the terminal and run:
cd ~/.ssh && ssh-keygen
Second, you need to copy this to your clipboard:
cat id_rsa.pub | pbcopy # On OSX
cat id_rsa.pub | xclip # On Linux
Third, add your newly generated ssh key to your account via the github/bitbucket website (just paste there).
Next, setup your git config:
git config --global user.name 'your_user_name'
git config --global user.email 'your_email'
Finally, restart your command line to make sure the config is reloaded.
Now, you should be able to clone and push from/to your github repository.
For more information on this, see this github page or this bitbucket page.
When attempting to clone, push, or pull over SSH with Git, you may receive one of these messages if Bitbucket couldn't authenticate with the keys that your SSH agent offered.
Here are the most common reasons why you may see these messages:
You used sudo when attempting the connection
You shouldn't use sudo when cloning, pushing, or pulling because the ssh-agent runs on the user level, not the root level.
Your public key isn't loaded into Bitbucket
To check if your public key is loaded into Bitbucket, do the following:
From Bitbucket, choose Personal settings from your avatar in the lower left.
The Account settings page displays.
Click SSH keys.
The SSH keys page shows a list of any existing keys.
If you don't have any keys listed, you can follow our Set up an SSH key documentation to set one up.
Your key isn't loaded into your SSH agent
If your SSH agent doesn't know to offer Bitbucket a key, the connection fails. You may run into this issue if you've recently restarted your system.
You can refer to this Article for more informations:
https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/
Check few things.
Is the generated new key is the one your ssh agent using when trying to ssh to server.
(Your ssh agent might be using a different key than the one you generated)
use this to list currently loaded keys by agent.
ssh-add -L
You properly added public key to your repository hosting location.
The keys corresponding to above 1 and 2 should match.
Please see this article: GitHub: Generating SSH Keys. What happens when you run:
ssh -T git#bitbucket.org
?
You may have added the wrong key to authenticate with.
I faced this error when I created another repository in my local. My ssh-keys were already set up and I was trying to push code through vs code.
The issue got resolved when I git push-ed through git bash like I was doing before.
For bit bucket I think I have tried everything with ssh. I have tried the answer from this stackoverflow question as well. But it doesn't work. So finally I just changed the clone command from SSH to HTTPS and it worked. Only then it asked for password for my account.

ant & cvs prompting password although password should come from PageAnt

I have ant build file, that should take cvs checkouts when called. I can call it ok, but when ant uses cvs to connect to cvs repo, the repo prompts for password and obviously ant command fails.
I have CVSROOT environment variable pointing to same location where I took the initial checkout for the project with TortoiseCVS, having ssh as protocol.
I also have putty's pageant running and an environment variable CVS_RSH pointing to plink.exe of putty. That combination should make the connection via putty, 'cause from pageAnt menu the connection opens without prompts.
My operation system is Windows 8.
Question here is, that why ant build fails on cvs server password prompt, although PageAnt otherwise is enabling promptless access via ssh+cvs?
Ant cvs task invokes cvs.exe command line from PATH so if everything works properly from command line, there is (almost) no reason it will fail from Ant.
Here is a checklist with points to verify:
CVSROOT must contain username and specify ext protocol, :ext:username#cvserver.domain.ldt:/path/to/repository
CVS_RSH must point to plink.exe with absolute file path and you have to ensure it will use SSH protocol
Your SSH private key must have been loaded into Pageant for the same user session as the user running Ant script
If it does not help, please provide more details about your cvs task options and your workstation setup.
When running without any user session opened and Pageant cannot help, often for continuous integration tools, a better option is to pass all arguments like username and private key file to plink directly in CVS_RSH variable:
CVS_RSH="C:\path\to\plink.exe -batch -ssh -l username -i C:\path\user\ssh-privatekey.ppk"
Of course, in such a case, your private key file must not be protected with a passphrase.

How to run batch file with credentials using Jenkins

I've mkdir commands in a batch file but only admins have permissions to create directory, so how to pass credentials from Jenkins job to the batch file.
mkdir \\%%S.domain.com\c$\Test
Select the "use secret text(s) or file(s) and then add a binding. See screenshot :
Yes Daniel, it might be done using such utility tools but my organization doesn't allow me to use third party tools without approvals. So, we have configured server with WinRM that allows to connect to server remotely using credentials.
Just to add to #Marc's answer, use the secret text Bindings as suggested to store and pass the username and password as environment variables.
The set the username variable to USERNAME and Password Variable to PASSWORD, then in your batch file use the net use command like so.
net use "\\server\share" %PASSWORD% /user:%USERNAME%
\* whatever you need to do on that share, e.g. xcopy, mkdir *\
net use "\\server\share" /delete

Resources