"mercurial-server: access denied" using ssh style URL - mercurial

I'm trying to user mercurial-server on a Raspberry Pi (conveniently at my desk before I ask the sysadmins to install on Ubuntu server). The Pi is running Raspbian Buster (recent update/upgrade routine). The ultimate goal is a set of repos for students such that they can't peek at each others' code, but I can clone any student's work for grading.
I have a small Mercurial repo testproject in my home directory. My id_rsa.pub key is in ~hg/.ssh/authorized_keys after running the Mercurial server refresh-auth script. In the log files I can see that my public key exchange worked. Everything in /var/lib/mercurial-server/ seems to be owned hg:hg, and the permissions look reasonable. I'm running from localhost to localhost so it's the same version of hg that's running at both ends. I can sudo -u hg hg init louis/testproject in hg's home directory and it creates the repo no problem (I deleted it before retrying from ssh).
$ cd testproject
$ hg clone -v --debug . ssh://hg#localhost/louis/testproject
What I get is:
running ssh 'hg#localhost' 'hg init louis/testproject'
mercurial-server: access denied
abort: could not create remote repo!
I also tried from Windows 10 (x64) with TortoiseHG. It starts working then just stalls, needing the Task Manager to kill the TortoiseHG workbench. I stopped trying that to remove complexity.
I'm hoping the problem is not the Pi, but I suppose I can always get a DO droplet running Ubuntu.
As always, thanks in advance.

Oh never mind... The access.conf file was incorrect.

Related

msys2 ssh: invalid key format (under Github CI only)

I am cloning repoB within GitHub CI workflow of repoA, using deployment key of repoB (stored in repoA). I understand this might not be a good practice, no need to comment on that (thanks).
The workflow tests this procedure natively on ubuntu-20.04 and using MSYS2 on windows-latest. It works on Ubuntu, I can run the commands manually on regular MSYS2 installation, but it fails on GitHub CI. The CI log has all the details, the essential command being
git -c core.sshCommand='ssh -vvv -i repoB_deployment_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' clone -b main git#github.com:eudoxos/repoB.git repoB
The failure under Windows is Load key "repoB_deployment_key": invalid format and I am not able to find out what's wrong. I tried changing permissions for the private key (chmod 600), adding the -o UserKnownHostsFile=/dev/null and -o StrictHostKeyChecking=no, running the key through unix2dos, adding extra trailing newline — nothing helped.
Again, the same command works under Ubuntu and under MSYS2 on desktop Windows.
The repos are publicly accessible fro reading; you are welcome to open a PR to the repoA repository; a PR should trigger the CI run.
Running the key through dos2unix (not unix2dos) fixed the issue. I will file that as an issue with msys2, as this should be documented.
Try in your GitHub workflow to display the key first, in order to visually check its content and its format (as seen here)
Check also which SSH you used when creating the key, the c:\Program Files\OpenSSH-Win64 one, or the one with Git for Windows (c:\Program Files\git\usr\bin\ssh.exe).

Mercurial on Jenkins, installing and configuring

I have a Mercurial repository (on Bitbucket) with some code (Java) and I want to do CI builds on a cloud-based Jenkins server (at Jelastic, running on CentOS). My problem is that I haven't been able to do a proper installation of Mercurial on the Jenkins server.
The Jenkins build fails with the following message:
ERROR: Failed to clone https://bitbucket_jenkins_user:some_password#bitbucket.org/repo_owner/my_repository because hg could not be found; check that you've properly configured your Mercurial installation
Setup information
It's a private Mercurial repository, hosted at Bitbucket
In Bitbucket I have set up a Service to trigger the Jenkins build, after a Push has happened
I have defined a specific bitbucket jenkins user in my Mercurial repository, it has only read rights and it logs in using simple https authentication
Jenkins runs on a Tomcat 7, hosted in a Jelastic cloud environment, on CentOS 6
The Mercurial plugin was installed through the Jenkins interface, by Manage plugins
The build is configured as being triggered remotely (by the service defined in Bitbucket)
Build results are the same when started manually and when triggered from a push to the repository
When I first did this I was under the impression that installing the Mercurial plugin in Jenkins would be enough, that it would also install the needed Mercurial binaries to be able to connect to the repository and get the code. I have realized that I was wrong and that on the Manage Jenkins / Configure System page I need to specify my Mercurial installation.
Questions
Is it possible to create a Mercurial installation without ssh access and doing a "yum install mercurial"?
In the Jenkins interface, what can I specify when choosing the "Install Automatically" option?
When defining an installer, I have experimented with the "Extract zip/tar.gz" option, but what can I write as the "Download URL for binary archive"?
Jenkins also offers an installer option of "Run command". What kind of commands could that be, maybe a "yum install ..." or "rpm ..."?
Since my server is cloud based, getting ssh access is a paid add-on which I would prefer to avoid. But if that is my only option I will of course do it, thereby getting access to running commands on the server. However, running "yum install mercurial" on Centos seems to only give the 1.4 version of Mercurial. Current version when I write this is 2.6.3, would I need to download the sources and compile it myself or is it possible to get that as a binary for Centos somewhere?
The Mercurial Plugin page has a section on how to use the Auto Installation options to install Mercurial using ArchLinux packages.
"The plugin supports generic tool auto-installation methods for your Mercurial installation, though it does not publish a catalog of Mercurial versions. For users of Linux machines (with Python preinstalled), you can use ArchLinux packages. For example, in /configure under Mercurial installations, add a Mercurial installation with whatever Name you like, Executable = INSTALLATION/bin/hg, Install automatically, Run Command, Label = linux (if desired to limit this to slaves configured with the same label), Command = [ -d usr ] || wget -q -O - http://www.archlinux.org/packages/extra/i686/mercurial/download/ | xzcat | tar xvf - (or …/x86_64/… for 64-bit slaves), Tool Home = usr, and configure a job with this installation tied to a Linux slave."
see https://wiki.jenkins-ci.org/display/JENKINS/Mercurial+Plugin

Alternative ways to deploy code to Openshift

I am trying to setup Travis CI to deploy my repository to Openshift on a successful build. Is there a way to deploy a repository besides using Git?
Git is the official mechanism for how your code is update, however depending on the type of application that you are deploying you may not need to deploy your entire code base.
For example Java application (war, ear, etc) can be deployed to JBoss or Tomcat servers, by simply taking the built application and checking it into the OpenShift git repositories, webapps or deploy directories.
An alternative to this (and it will be unsupported), is to scp your application to the gear using the SSH key. However any time the application is moved or updated (with git) this content stands a good chance of getting deleted(cleaned), by the gear.
We're working on direct binary deploys ("push") and "pull" style deploys (Openshift downloads a binary for you. The design/process is described here:
https://github.com/openshift/openshift-pep/blob/master/openshift-pep-006-deploy.md
You can do a SCP to the app-root/dependencies/jbossews/webapps directory direcly. I was able to do that successfully and have the app working. Here is the link
Here is the code which I had in the after_success blck
after_success:
- sudo apt-get -y install sshpass
- openssl aes-256-cbc -K $encrypted_8544f7cb7a3c_key -iv $encrypted_8544f7cb7a3c_iv
-in id_rsa.enc -out ~/id_rsa_dpl -d
- chmod 600 ~/id_rsa_dpl
- sshpass scp -i ~/id_rsa_dpl webapps/ROOT.war $DEPLOY_HOST:$DEPLOY_PATH
Hope this helps

HG clone returns "abort: HTTP Error 406: Not Acceptable" on Redmine VMWare computer

I'm really new with SCM systems, so I'm starting to study Mercurial, but I'm facing a problem that I have no idea how to fix. I hope someone can point me the right direction :-) :
So, I have installed the BitNami Redmine Stack (http://bitnami.org/stack/redmine) on a Vmware computer with windows 2003 (64 Bits) as the OS. On the same VM I have installed Mercurial-2.3 (Mercurial 2.3 Inno Setup installer - x64 Windows - does not require admin rights) , and restarted. after that , created a directory (e:\helloworld) and I have initialized the directory with some basic the HG commands (HG Init, HG Add, HG Commit).
Using the host computer to confirm the correct communication with the VMWare guest computer, I have created a small project in Redmine, added a repository with Mercurial as the SCM and included the initialized directory (e:\helloworld on the server). The repository is displayed correctly in Redmine, and, working directly in the virtual computer if I do some changes and perform some commits, the changes are displayed in the Redmine repository. From my current limited knowledge, all seems to be ok when I work directly in the VM, but when I try to clone the directory using HG clone from the host computer, the server responds:
C:\helloworld>hg clone http://redminevm/redmine/projects/helloworld
abort: HTTP Error 406: Not Acceptable
I also have tried with the IP address instead of the hostname, adding the username and the password to the URL, or initializing the local folder previous to try the hg clone. all my attemps return the same result. I'm assuming something is incorrect in the server, but I have no idea what it can be.
What should review on the server (or Client), in order to allow me to clone the Mercurial repository thru http?
Thank you very much in advance!
Alex.
Ok, after investigating, and with a big help from the Redmine forum, I can answer my own question. I hope my experience can help someone. My question was because of lack of knowledge about Redmine and what it can and cannot do.
so;even if we can have repositories in a RedMine project, RedMine is not a repository server. Means I can link a repository to a project, but, if I want work on it thru http (or serve multiples repositories) , aditionally I need install a server like rhodecode, or use hg serve. :-)
Saying this, I was doing this incorrectly. After running hg serve , I was able to serve multiples repositories.
Same error if you want to clone a git repo with "hg clone". Yeah, I know, I'm an idiot, but it happens, probably this will help someone.

How do i set a private ssh key for hudson / jenkins to access bitbucket?

I'm trying to set up a Debian server with Apache2 as a front end to Tomcat 7 running Jenkins - which is working - but i want Jenkins to monitor a private Mercurial repository hosted at bitbucket and I'd like to use SSH. (I've tried with plain https but still no joy - there is a question answer here on SO that recommends using ssh)
I've deployed Jenkins using the hot deploy capability of Tomcat by dropping the Jenkins .WAR file into /webapps. I can generate a public/private key pair on the server and have added my public key to the bitbucket account - but how do I make Jenkins use my private key to authenticate when accessing a private repository on bitbucket?
I've seen a blog post that uses apt-get to install Hudson on Debian which creates a Hudson user (so i could add a private key for this user) but installing it via the tomcat autodeploy doesn't add a Jenkins user. If there is no unix user set up for Jenkins, can I configure one that Jenkins would use when authenticating?
If you can control the mercurial command line from within Jenkins you can pass the --ssh command to tell mercurial what ssh command to invoke. Something like this would probably work:
hg --ssh '/usr/bin/ssh -i /path/to/private/key' ...
Alternately you can figure out what user Jenkins is running as (it's got to be some user) and put the file in that user's ~/.ssh even if that's /root/.ssh/