How can I add SSH ID to bitbucket? - ssh

I am trying to add my SSH ID to bitbucket from my newly installed ArchLinux setup. The instructions for adding my id to bitbucket involve using my browser and copy/paste the key. I am not using a GUI but don't know what the command is to push public keys from commandline to bitbucket. How do I manage this?

You could try to use the links command line browser, although it doesn't seem installed by default. Of course you may want to get the ID into a clipboard of sorts if you don't want to type it over.
If the posting the ID doesn't require difficult pages and settings you may be able to implement this using httpie - which does seem to be installed.

Related

How do I tell the GitHub CLI to use a specific SSH key?

I have various GitHub accounts and for each account I have SSH set up. So under ~/.ssh I have a public and private key for each account.
I want to use the GitHub CLI, but I am not sure how I can tell the CLI to use a particular SSH key.
In case it is relevant, this is what I get when I run ssh-add -l:
Example Scenario
I want to run gh repo create on GitHub account B, but for some reason, the repo got created on GitHub account A. Is there a way I can tell gh what account to use?
if you have different GitHub users the gh-cli won't be very effective. as #phd commands like gh repo create require logging in via an auth token. https://cli.github.com/manual/gh_auth_login
Switching contexts between accounts (i.e. github.com/user1 and github.com/user2) def doesn't seem supported so you'd have to hack around loging in and out each time every time you switched.
But configuring which ssh key git should use can be configured easily enough in some combo of ~/.ssh/config .gitconfig and/or setting the GIT_SSH_COMMAND env var before running git commands.

Generate key files to connect to Bitbucket in Vagrant boxes

We use Vagrant boxes for development. For every project or small snippet we simply start a new box and provision it with Ansible. This is working fantastic; however, we do get into trouble when connecting to a private Bitbucket repository within a bower install run.
The solution we have now is to generate a new key (ssh-keygen), accept all defaults (pressing <return>, <return>, <return>) and then grab the public key (cat ~/.ssh/id_rsa.pub). Copy it, go to Bitbucket, view your account and add this new ssh key. And repeat for every new box you instantiate.
We have to do this because of some closed source packages (hosted on Bitbucket) we install via Bower. We do have another experience, which is much better: composer (php's package manager) and private Github repositories. With that setup, you have to enter your username/password/2fa token via the command line and an OAuth token is generated for you. This works great.
So, is there a way we can mitigate this bower/bitbucket/ssh issue? For obvious reasons I don't want to provision the boxes with a standard private key, but there has to be another solution?
While I'm not sure that my situation is as complex as yours (I'm not using Ansible or Bower), I solved this problem by using the Vagrant ssh forward agent. This blog post gives you the details on how to get it working:
Cloning from GitHub in Vagrant using SSH agent forwarding
So as long as each of the developers has access on their local machines to the bitbucket repos, it should work.

Can I change gerrit authentication type from openid to ldap?

We in our team are planning to use gerrit. So, to get introduced, I did set up a server, used open-id for authentication and created some test-users and test-projects in it.
Now we are ready to use it. But we actually prefer LDAP for real use.
So, can I change my authentication system from open-id from LDAP? What will happen to current users then?
I want to clear test projects and changes. How can I do them?
Can I complete delete existing gerrit setup and initiate a fresh setup in same machine? (I tried extracting the jar in different folder, but I faced some problems in it)
I am using Ubuntu 12.04 as my server.
Please help.
Delete the database (you're not using the H2 database anymore, but some MySQL or PostgreSQL server, don't you?) plus the directory where Gerrit is running (the -d parameter, see docs). Additionally, remove the git repos, if you configured them to be located on a different path.
Then all your data is gone and you can start from scratch.

How do I mount/unlock my custom (!) ecryptfs directory on login?

I think I need to add a key from the user keyring to the kernel keyring on login for this, but let me just explain the whole thing:
I have a custom ecryptfs directory set up with a huge annoying passphrase, because Ubuntu refuses to implement support for key files:
2011: Unfortunately, we're not building ecryptfs against ssl at this time, due to license incompatibilities (as noted below). I'm going to leave this bug open, though, and try and get those sorted out.
2012: there are no plans to improve this feature in the near
term. It is a considerable amount of work, yet no developers have shown
interest in the feature.
I want to mount/'unlock' this ecryptfs directory automatically when I log in, without having to enter this annoying passphrase manually. With an encrypted home in Ubuntu (also ecryptfs) this happens with a key that is unwrapped using the login password, but this does not work for custom mounts.
For other uses (e.g. LUKS) you can simply store the key/passphrase in your user keyring. But because ecryptfs works in the kernel, this key needs to be stored in the kernel keyring, not the user keyring.
Manually, you would add the key to the kernel keyring using ecryptfs-add-passphrase or ecryptfs-manager, after which you can mount and unmount the ecryptfs directory as much as you want. But after a reboot, this key is gone again, and with good reason.
But I want it back automatically after I login with my user so I can mount/unmount the ecryptfs directory again without having to enter it's password. How can I do this?
update
On Archlinux there is this tool called ecryptfs-simple developed specifically for this purpose: ecryptfs-simple is a utility for users that want to work with eCryptfs in the simplest way possible. The idea is to make eCryptfs as easy to use as EncFS.
Apparently, you can setup automatic mounting with ecryptfs-simple -a, but this tool is not available for Ubuntu, and I don't know if this setup survives a reboot.
It sounds like you want to manipulate keys, so keyctl might be your weapon of choice. Unless you're referring to some other Ubuntu-specific keyring I'm unfamiliar with. From man keyctl I can copy a key from the root/sudo/(kernel?) keyring into my user keyring with this command, something similar should work for you:
sudo keyctl pipe (wantedkeyid#) | keyctl padd user newkeydesc #u
And maybe you've already read ArchWiki's excellent article on using eCryptfs. https://wiki.archlinux.org/index.php/System_Encryption_with_eCryptfs#Auto-mounting
It's got info on using Ubuntu tools, or eCryptfs manually, and a section on auto-mounting (with PAM). Or maybe a simple bash script to ecryptfs-add-passphrase (reading your keyfile) & mount your folder would be easier? And ecryptfs itself supports reading the passphrase from a file too with passphrase_passwd_file=, see man ecryptfs
You need to store the passphrase somewhere, and then you can mount the filesystem automatically. But it's probably a bad idea — to save the key locally.

how can I acces a Github repo from a 2nd machine?

Although there is a number of questions on the topic, I'm not getting anywhere....
I need to access an existing repo on Github from an alternate machine and I'm having trouble setting it up.
So I have installed Github and ran:
git config global --user.name
git config global --user.email
git init
git clone git#github.com:user/repo.git
I'm getting Permisson Denied (publickey)
Which I guess is due to me not having provided my SSH key. I have the key here, but no clue, what to do.
Question:
How to do I supply the SSH key to be able to connect my 2nd PC to my git repo.
Thanks!
You need to register another ssh key with github for the second computer.
Go here and add another key. This page explains the process.
You can switch to https authentication if you don't want to generate another pair of key or transfer your existing one to the new box.
You will need to change your clone command to following: git clone https://github.com/user/repo.git
Their help section has a nice step-by-step guide to setting up your machin: https://help.github.com/articles/generating-ssh-keys#platform-all.
Specifically, see step 4 for instructions on how to import a new key.