Unable to access cvs public repository anonymous access - gitlab

I am trying to migrate cvs to git repository. I tried to test how it works. So I tried to access cvs public repository using the doc
There is support to access cvs repositories with an anonymous account with an empty password, but I am unable to access it.
cvs -d :pserver:anonymous#cvs.infodrom.org:/var/cvs/$repository login
Logging in to :pserver:anonymous#cvs.infodrom.org:2401/var/cvs/config
CVS password:
cvs [login aborted]: unrecognized auth response from cvs.infodrom.org: /usr/bin/cvs: unrecognized option '--allow_root=/var/cvs/debian'
How can I access cvs repository with an anonymous user?

Two points:
Try using infodrom rather than config as a $repository value as that's what's documented here: http://www.infodrom.org/projects/cfingerd/cvs.php and in similar projects i.e.
cvs -d :pserver:anonymous#cvs.infodrom.org:/var/cvs/infodrom login
You normally need the whole server-side repo to do a proper cvs2git, not just a client-side checkout. Which you cannot get from a repo on the web, you can only get if you are the sysadmin on your own cvs repo.

Related

Cloning Terraform GitHub module inside private org - permission denied

I have the following module that we are trying to clone via SSH (NOTE: we prefer to not use https) in Terraform:
module "example-module" {
source = "git#github.com:private-org/example-module.git?ref=v1.0.0"
}
However, we have a GitHub actions runner that fails when trying to do a terraform init on this module:
Permission denied (publickey). Could not read Password for
'https://***#github.com': No such device or address
So to give this permission, we are trying to add inside .gitconfig:
[url "https://{GITHUB_TOKEN}#github.com"]
insteadOf = "ssh://git#github.com"
And inside the GitHub actions we are trying to replace GITHUB_TOKEN with the actual value:
- name: Configure SSH
run: |
sed -i 's/{GITHUB_TOKEN}/${{ secrets.GITHUB_TOKEN }}/g' .gitconfig
cat .gitconfig >> ~/.gitconfig
But we are still getting the same error. Any ideas for how we can authenticate to a private module inside our GitHub org and successfully clone via SSH?
Figured out the answer. The default GITHUB_TOKEN did not have have the right access rights and was not deemed a "Personal Access Token". This seems a little confusing on GitHub's part and the reason it was getting the error Could not read Password
You will need to generate a new personal access token in GitHub, and add that as a GitHub Actions secret called NEW_GITHUB_TOKEN. Add read:repo and write:repo as access rights and set the token to never expire.
Your .gitconfig should look like:
[url "https://{GITHUB_TOKEN}#github.com"]
insteadOf = "ssh://git#github.com"
And a step in your GitHub Actions that uses your new personal access token:
- name: Configure SSH
run: |
sed -i 's/{GITHUB_TOKEN}/${{ secrets.NEW_GITHUB_TOKEN }}/g' .gitconfig
cat .gitconfig >> ~/.gitconfig

Getting 'forbidden' pushing a nuget package in github

Much like this thread: Publishing and Consuming GitHub Package Repository with NuGet: Unable to load the service index error
I have the csproj correct, the nuget.config correct (same as in that thread, but for my username), and following the answer where the token has all the rights, and I do the dotnet nuget add source, and the dotnet nuget push (same formatting/syntax).
However, I always always get this:
warn: <username> does not have the correct permissions to execute 'CreatePackageVersion'
Forbidden https://nuget.pkg.github.com/(username)/ 687ms
error: Response status code does not indicate success: 403 (Forbidden).
I've tried with/without the -k (git token) in the dotnet nuget push, no effect. The --interactive that it recommends, doesn't change anything.
I'm running this in a standard command line in the \bin\Release\netstandard2.0\publish directory, after having published to that folder.
Did already restart computer even after adding appropriate csproj and nuget.config data. Also tried doing #username and username (my username with and without an at sign, since all docs have no actual username examples, many blackened out).
(I do want it to be public readable, already added source .../(username)/index.json).
Check the RepositoryUrl in your csproj. It should match the repository you're uploading packages to. You may also need to set PublishRepositoryUrl.

Personal Access Token not working on Linux

I am using Git on Linux.
I followed this to create a Personal Access Token but forgot to save it.
Therefore, when I was asked to enter the "password" again, I deleted the old PAT and created a new PAT. For some reason, the new token is rejected and I get
fatal: Authentication failed for 'https://github.com/username/***.git/'
When I look at the tokens page on github, this token says it was never used. What might be the issue here?
The issue might be with your current credential helper.
Type git config credential.helper to see which one is used.
Type:
printf "protocol=https\nhost=github.com"|git-credential-xxx erase
(Replace xxx by the credential helper name from the first command output)
That will clear out the cached credentials for https://github.com.
Then try again a git push, and see if it asks you for your credentials: enter your new PAT as password.
If you don't have a credential helper, I suggest installing microsoft/Git-Credential-Manager-Core (there is a Linux package).
Add a credential store, and you are set.
After discussion:
there was no credential helper
this is a personnal account (not a technical service one, used by multiple users)
the issue was with pasting the token
I would therefore use a store credential caching:
git config --global credential.helper 'store --file /home/<user>/.my-credentials
Then:
git ls-remote https://github.com/<user>/<repo>
That will trigger the prompt for your username and token.
Edit /home/<user>/.my-credentials and make sure the right token is in it.
Alternatively,
git config --global credential.helper 'store --file /home/<user>/.my-credentials'
and then:
git ls-remote https://<user>:<token>#github.com/<user>/<repo>
has worked.
I had to delete my token and create a new one and it worked for me

Node.js - Clone .git repository using a personal access token and simple-git

I have a Node.js app. I want to clone a private repository from GitHub using this app. I have access to this repository. In an attempt to clone the repository from my Node.js app, I'm using simple-git, with the following code:
const git = simpleGit();
git.clone('[repository-url]', './repository');
This code runs successfully. A directory named repository with the following structure is created:
/repository
/.git
.gitignore
However, this is not the contents of the repository. I successfully cloned a public repository using this code. This makes me believe that it's an authentication issue, even though no error is being shown. I created a Personal Access Token and stored it in an environment variable. However, I can't figure out how to actually use that Personal Access Token when I clone my private repository.
How do I clone a private repository using a Personal Access Token using simple-git?
You can use the config plugin to add your access token as a custom header:
const git = simpleGit({
config: [
`Authorization: token ${TOKEN}`
]
});
You can also set up a .netrc file with your auth details which simple-git will pick up by default.

Is there a way to obtain the directory structure of a gitlab repo using python

Is there a way to get a list of files and directories in the gitlab repo using python? So if I use the gitlab repository url as my source, can I traverse and get a list of all files and directories/ sub-directories within the repo? Like using os.walk but for a web url.
Can you try python-gitlab?
Use repository_tree method can do it for you.
Here is the code
import gitlab
gl = gitlab.Gitlab.from_config()
# Get a project by ID
project_id = 851
project = gl.projects.get(project_id)
branch = {your branch}
directory = {your directory ref to root directory of the repository}
project.repository_tree(direcotry, ref=branch)
For more details, please visit python-gitlab

Resources