Gitolite intermittent issue: 'bad interpreter: Permission denied' - teamcity

I have an issue when TeamCity connects to the git server. We use gitolite
Error message
Failed for the root 'myroot' #84: List remote refs failed: org.eclipse.jgit.errors.NoRemoteRepositoryException: git#mygitserver:repo.git: bash: /home/git/.gitolite/src/gl-auth-command: /usr/bin/perl: bad interpreter: Permission denied
This issue occurs intermittently.
Do you have any ideas how can I identify and fix the root cause?

Check if any of the perl script have a ^M (in which case a dos2unix would fix it).
But for the permission denied part, as in this thread, check if the partition is being mounted noexec (mount).
Especially the /tmp one, which can be used (or not used) depending on gitolite operation.
sudo mount -o remount,exec /tmp

Related

Bash scripts getting permission denied

This problem has been a thorn in my side for months and I cant find a solution or a reason behind this. I work with bash scripts a lot and I find that half the time when i execute a .sh script that calls another .sh script, I'll get permission denied during certain sequences of the execution. Sometimes on cp, mkdir, git commands, and sometimes it can execute just fine. If I prepend sudo they work, but my coworker runs the same scripts and never has these issues. So what am I missing?
Another use case:
running command "sudo npm install go-npm",an error code pops up:
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/brockwood/spawn-sync.git /home/epoauto/.npm/_cacache/tmp/git-clone-d4bf86cc
npm ERR! /home/epoauto/.npm/_cacache/tmp/git-clone-d4bf86cc/.git: Permission denied
I've given sudo permissions with 'sudo visudo' but no luck.
Please help!

Rsync errors on windows with DeltaCopy

Previously I got this working on my workstation, but since I formatted it, rsync stopped to work.
I already reinstalled git and deltacopy a couple of times.
Also had registered rsync as a service on windows.
Every time I ran the command, I got these errors.
If I type a wrong password, I get access denied, so the connection is ok.
C:\\> rsync -v -rlt -z --chmod=a=rw,Da+x --delete
"/cygdrive/C/P21 Sistemas/web/apache/local.sdt21/sdt21/"
"root#sdt21.com.br:/home/sdt21/homologacao/www/sdt21/"
root#sdt21.com.br's password: *********
dup() in/out/err failed
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at
/home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(791) [sender=3.0.4]**
The problem is with the ".
The quote is a known issue on Windows.
In order to override the problem install cygwin & rsync:
See: Using rsync and cygwin to Sync Files from a Linux Server to a Windows Notebook PC
And then write your command in a shell script and execute it.

Permission denied when installing ruby

I am working on installing another version of ruby on another server which is CentOS 6.7 When while trying to configure ruby within the tmp directory I receive a:
sudo: unable to execute ./configure: Permission denied
Here is exactly what I am doing leading up to this:
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xz
cd ruby-2.1.2
./configure --disable-install-rdoc <!-- here is were we fail with permission denied
I am currently logged in as root. I have played around with changing my file permissions and that did not seem to help at all.
Any suggestions?
From this link it appears /tmp is mounted as read-only.
Open /etc/fstab, find the line that mounts your /tmp dir, and remove the noexec flag. Then remount the filesystem (or simply restart your system).
As a side note, you will also want to avoid running ./configure and make as root user. Only when it comes to run make install should you run as root.

remove .git/index.lock': Permission denied

I'm completely stuck as to why my git has completely locked me out. I have a laptop that I use at work and when I'm home. For both accounts I use git extensively and both are located in different paths. Today I came into work and I can't do anything, all I see is:
/Applications/MAMP/htdocs/my_site/.git/index.lock': Permission denied
For all I care the branch I'm on can be deleted. I've tried removing the branch, checking out any other branch, removing the index.lock file (as suggested by other users on sites). I only have the terminal window open, no other possible programs using git (as far as I know and nothing noticeable in the activity window). I have rebooted the computer straight into my work account and still no luck. How can I remove this lock?
I had the exact same problem wanting to commit my changes to git, and solved it this way:
I needed to change the group of my .git folder and its contents:
sudo chown -R <owner>:<group> .git
needed to change the permission of this folder:
sudo chmod -R 775 .git
Check which user owns the git lock:
ls -la /Applications/MAMP/htdocs/my_site/.git/index.lock
Then you can use sudo to remove it.
After updating xcode you are maybe asked for agreeing to the new license.
git init
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
When you do this
sudo git init
you'll get a root user .git dir
drwxr-xr-x 10 root XXXX 340 25 Sep 12:40 .git
If you call other git commands which create files, these files are also created for the root user.
Change the permissions or remove .git if you don't need it yet.
=> Don't ever call git with sudo!!!
If your are asked to just call git on an empty directory
mkdir foo
cd foo
sudo git init
I had this issue as I running the following command
sudo git fetch && git checkout<branch>
Note the second sudo was missing. Running the following solved the issue:
sudo git fetch && sudo git checkout<branch>
You shouldn't have to change the owner ship of the .git directory when running sudo.
I was experiencing the same issue when trying to update the submodules of my repo:
$ git submodule update
fatal: Unable to create '.../.git/modules/deps/luajit/index.lock':
Permission denied
Unable to checkout '04dc64b558025e76a820f89a8e41840bf8269f32' in
submodule path 'deps/luajit'
It seems the problem was the submodules belonged to a different user, so I set back the ownership to me:
cd .git/modules/
chown -R user.group *
My computer system is Windows. When I open WSL remote vscode and local vscode in this path, system show this error. I closed remote vscode WSL and it solved this problem.
Change the permissions from root to the current user for the /.git folder
sudo chown username .git
Checking permission is surely the way. I faced this error when logged in with the wrong account. So, answer from my personal experience is:
"Be sure you logged in with the correct account".

error: cannot run ssh: No such file or directory when trying to clone on windows

I am trying to clone a remote repository on Windows, but when I did this:
git clone git#github.com:organization/xxx.git
I got this error:
error: cannot run ssh: No such file or directory
fatal: unable to fork
Am I missing something?
Check if you have installed ssh-client. This solves the problem on docker machines, even when ssh keys are present:
apt-get install openssh-client
You don't have ssh installed (or don't have it within your search path).
You can clone from github via http, too:
git clone http://github.com/organization/xxx
Most likely your GIT_SSH_COMMAND is referencing the incorrect public key.
Try:
export GIT_SSH_COMMAND="ssh -i /home/murphyslaw/.ssh/your-key.id_rsa
then
git clone git#github.com:organization/xxx.git
I am aware that it is an old topic, but having this problem recently, I want to bring here what I resolve my issue.
You might have this error on these conditions :
You use a URL like this : git#github.com:organization/repo.git
And you run a kind of command like this directly : git clone git#github.com/xxxxx.git whereas you don't have ssh client (or it is not present on path)
Or you have an ssh client installed (and git clone xxx.git work fine on direct command line) but when you run the same kind of command through a shell script file
Here, I assume that you don't want to change protocol ssh git# to http://
(git#github.com:organization/repo.git -> http://github.com/organization/repo.git), like my case, cause I needed the ssh format.
So,
If you do not have ssh client, first of all, you need to install it
If you have this error only when you execute it through a script, then you need to set GIT_SSH_COMMAND variable with your public ssh key, in front of your git command, like this :
GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/id_rsa" git pull
(Feel free to change it depending on your context)
I had this issue right after my antivirus moved the cygwin ssh binary to virus vault, and restored it after.
Symptoms:
SSH seems properly installed
SSH can be run from command line without problem
Another option before reinstalling ssh in this particular case: check the ssh command permissions
$ ls -al /usr/bin/ssh.exe
----rwxrwx+
$ chmod 770 /usr/bin/ssh.exe
You can try these as well
ssh-add ~/.ssh/identity_file
chmod 400 ~/.ssh/identity_file
It so happened in my case that the new pair of ssh keys linked with my git account were not accessible.
I had to sudo chmod 777 ~/.ssh/id_rsa.* to resolve the issue.

Resources