Categories
Freedom and Privacy Tutorial Ubuntu Touch

How to set up Gitlab with Ubuntu Touch 2FA Manager App

I had been using Ubuntu Touch Authenticator app, but I wanted to try out the 2FA Manager app to see how that worked for me. The only problem was that I had never reset my 2FA stuff that I originally set up so this was my first time switching devices. It was easy, but it was also not documented. I hope this simple guide helps and perhaps the steps of this process also apply to other 2FA sites:

In your Gitlab account

  1. Log into your gitlab account
  2. Go to “Settings” under your top right avatar
  3. Go to “Account”
  4. Click the ‘Manage Two Factor Authentication” button
  5. Click the ‘Disable two-factor authentication’ button which will then warn give you this warning “Are you sure? This will invalidate your registered applications and U2F devices.”
  6. Select ‘Ok’ on warning screen

This will now present you with a screen and QR code where you will scan it and bring it into the Ubuntu Touch 2FA Manager app. So now let’s move to your ubuntu touch device…

On your Ubuntu Touch device

  1. Download / install tagger app if you have not already done so
  2. Download install the 2FA Manager app if you have not already done so
  3. Open the 2FA Manager App
  4. Open Tagger app and point camera at QR code and patiently wait… adjust camera position if needed until it registers the QR code. You will know this is working when the dialogue with “open url, copy to clip, generate qr code” buttons pops up
  5. Select ‘open URL’
  6. Add a description. This is just a friendly name that will help you remember what this key is for as you may build up many keys over the years.
  7. Press ‘Add’ button. You should now be taken to the 2FA Manager app to a screen with a 6 digit bold code and a purple progress meter that is moving. You will notice that each time the progress meter reaches the end, it will loop back with a new 6 digit number. You will also notice that if you tap this 6 digit code it will open it up and make it much bigger and easier to read and also give you the ability to copy this code to clipboard. Whichever way you prefer, these are the two ways you can obtain your 2FA codes and these codes are what you will use to log into Gitlab each time, and also to use to finish up your setup in your Gitlab account.
  8. Go back to Gitlab

Meanwhile, back at Gitlab…

  1. Look at your 2FA Manager app and grab the 6 digit code presented on the screen. But hurry! (dramatic music here) If you don’t grab it quick enough the next one will be generated. This is for security if you were wondering and limits the chance of someone stealing your stuff…
  2. Enter the 6 digit code into the ‘pin code’ field on your Gitlab 2FA setup page you should still be on
  3. Select ‘Register with two-factor app’ button
  4. Save your recovery codes: If all goes well you should now be presented with a ‘congratulations’ screen and a list of 10 random looking letters and number strings with bullet points. These are your recovery keys so save them somewhere safe. I recommend the keypassxc app as it’s a really great password manager for your laptop / desktop ubuntu environment.
  5. After you have these recovery codes safely stored, press ‘proceed’. If you got an ‘invalid code’ message, it probably means you weren’t fast enough with steps 1-3 above so repeat but faster 😉

You should now be brought back to your gitlab Account page and good to go. You can probably use this workflow above to do 2FA setups in other systems as well.

Categories
Technology Tutorial Ubuntu Touch

How to do an Ubuntu Touch Video Screen Cast Recording

Making a video screen cast of your Ubuntu Touch (“UT”) device is a bit difficult as of the date of this blog post, however, thankfully, there is a way to do it with a bunch of scary terminal commands.

This is pretty technical, but is probably the only way (for now) to do this. Special thanks to Amolith who forwarded to Joe (“in here”) who then forwarded it to me. The power of free software communities at work!

First, I’ll just give you the commands in case you are already familiar enough with terminals and commands. Then, I will provide detailed how-to to follow.

Record a big raw video file in interesting .raw format

EDIT 20/06/21
This first command has been updated to reduce ‘terminal weirdness’. Now it works quietly in the terminal. Special thanks to Rodney for that excellent improvement.

adb exec-out timeout 120 mirscreencast -m /run/mir_socket --stdout --cap-interval 2 -s 384 640 > ubuntu_touch.raw

Convert it to ‘normal’ format (mp4) with ffmpeg tool

ffmpeg -f rawvideo -pix_fmt rgba -s:v 384x640 -i ubuntu_touch.raw -filter:v "setpts=2*PTS" ubuntu_touch.mp4

I plan to give a few more how-to details next by editing this blog post but for now I at least wanted it logged somewhere where myself and others can easily find it.

Enjoy

Tutorial – How to actually do it.

Before you begin

I would recommend creating a directory / folder just for doing this stuff. Then, you will navigate in your terminal to this directory. That makes sure that all the video is dumping in a place where you’ll be able to find it and work with it easier. Otherwise, your terminal might autonomously dump it an undesired location (your Home directory if you left everything default…). Once you have created this directory, navigate to it with the terminal’s ‘cd’ command. If you don’t know how to do that, take a few minutes to search and learn? It’s a good life skill and you can brag about it at the coffee machine or water cooler…

Now that you have the scary command line codes above ready to copy and paste, here’s how you do it and what to expect.

First, you’ll have to make sure you have adb setup on your ‘production machine’ (the machine that is recording the Ubuntu Touch output video. You should be ok to just do the usual sudo apt install adb and then perhaps you’ll need to be in ‘Developer mode’ to do all this. You might find that your system already has adb. If so, it will tell you that your version is up to date, etc and you can continue. If you need either of these or find it’s not working right, this blog has a lot of good info in one place. Most should be current still at the time of this post.

Next, plug in your UT device and get ready to record. Probably a quick test video is wise, by the way, before you start recording a long meaningful video.

Next, run the first command above by copying/pasting into your terminal. You will see this (or something very similar) in the terminal. Just pretend this means “your raw video is now recording to your production machine” because that’s what’s happening even though you can’t see it:

daemon not running; starting now at tcp:5037

daemon started successfully

When you are done recording, go back to your terminal and press ‘control C’ in to stop the process. You will see absolutely nothing except your ^C. Just pretend this means ‘Your raw video file has now stopped recording and is sitting in the directory where you started it”.

Finally, you’ll need to convert the raw video to a human-usable format – and probably mp4 is what you’re looking for which is why the above command is setup the way it is. Note that if you want to do any other million different things with your video work, you could study the power of ffmpeg and do whatever you like with formats, resolutions, etc, etc….

Now, in your terminal after you run the converting command, you are going to see a lot of ‘stuff’ in your terminal. I’m not going to even paste it here because there is so much. I’m also not going to pretend I know what any of of it means. Just be aware this is ‘normal’.

Once complete you should now have a .raw video and a .mp4 video in your screen casting directory.

Double click your .mp4 file to make sure it’s working and enjoy your new Ubuntu Touch video screen recording.

Categories
Freedom and Privacy Technology Tutorial Ubuntu

How to use this Bmap Tool Thing…

So someone said ‘use bmap tools instead of dd because it’s faster and better’.
It sounded good but as usual when I went searching for documentaion on how to simply use this tool I was left in another command line dizziness. You can check their read me file on the git repository here for yourself if you’d like. This blog here was also even better than the read me file, so thanks to whoever this is as well.

So, hopefully this blog will help you step by step setting things up because I can confirm indeed this thing is blazingly fast compared to dd or other direct image copying things!

Assumptions

  • you are running Ubuntu
  • You know how to find your terminal and type in it
  • you want to flash / copy something to something 🙂

1. Get Bmap

sudo apt install bmap-tools if you have not done so already. This will install in ubuntu

2. Create your Bmap file

This is the thing that seemed to be not explained anywhere well. So what this step does it it creates a file formatted as ‘.bmap’. It’s an xml file. Somehow this file is what makes the magic work so if you create it with the bmap tool and use it in the bmap command line, copying is way faster.

Name your bmap file

You can name this file anything you want. I chose to call it something completely different from my image file so that I don’t accidentally type a wrong command. In my case I was flashing a pinephone image to a micro SD card so I named the bmap file ‘pphone.bmap’ and then the image file remained the way I downloaded it as ‘ubuntu-touch-pinephone.img.xz’.

Select a location

Next, select a nice directory on your computer where you want to run these commands. You can make your own directory or just use the Downloads directory – it’s up to you. I’ll use “Downloads’ for my example.

Run the bmap file creation command

This part here will create the bmap file now that you’ve thought everything through. Just open a terminal and enter this:

bmaptool create /path/to/your/image > /path/where/you/want/bmap/file/saved/bmapfilename.bmap

Here is my actual example with some filled in info:

bmaptool create ~/Downloads/ubuntu-touch-pinephone.img.xz > ~/Downloads/pphone.bmap

— PLAY BY PLAY COMMAND COMMENTARY —

  • ‘bmaptool’ calls the app.
  • ‘create’ : a bmap tool command that says ‘make a bmap file’
  • ~/Downloads/ubuntu-touch-pinephone.img.xz: the location of your image
  • ‘>’ thing is… who knows! But it does stuff
  • ~/Downloads/pphone.bmap: destination of where you want your .bmap file to end up.

Press enter and you should see an output in your terminal something like this:


bmaptool: WARNING: all 826.3 MiB are mapped, no holes in ‘/home/wt/Downloads/ubuntu-touch-pinephone.img.xz’
bmaptool: WARNING: was the image handled incorrectly and holes were expanded?

wt@wt-Lemur:~$ cd Downloads/


Not sure what the warnings were but it seemed to be ok 🙂

3. Copy / Flash your image to your desintation drive, card, whatever

Now that you have your .bmap file created (and you should go to that directory to make sure before proceeding, by the way) you are ready to start blazingly fast copying! Woot woot. This is a simple change from the command above. If you look at my example, I think you’ll figure it out pretty quick.

Note 1: Sudo required for this one.
Note 2: Be CAREFUL before you hit the enter key because if you map this to the wrong desintation, you could damage stuff. I always remove any external drives I don’t want to accidentally kill 🙂

sudo bmaptool copy --bmap ~/path/where/your/bmap/file/is/located /path/where/your/image/is/located /path/to/memory/device

Here is my example with stuff filled in:

sudo bmaptool copy --bmap ~/Downloads/pphone.bmap ~/Downloads/ubuntu-touch-pinephone.img.xz /dev/mmcblk0

  • — PLAY BY PLAY COMMAND COMMENTARY —
  • ‘sudo’ -gives you super powers
  • ‘bmaptool’ calls the app.
  • ‘copy’ is the command to copy (smart name…)
  • ‘–bmap’ : says ‘hey! here’s my bmap file so you copy this thing fast”
  • ‘~/Downloads/pphone.bmap’ : this is the path to my bmap file
  • ‘~/Downloads/ubuntu-touch-pinephone.img.xz’ : this is the location of my image that I want to flash onto something. In my example it’s the pinephone image
  • ‘/dev/mmcblk0’ : the destination of where you want your .bmap file to end up. This this case it’s the SD memory card but yours could be /sdc /sda or whatever depending.

Here is the output of my terminal doing this. I find it’s helpful to see terminal stuff so you don’t think you’re going crazy if stuff looks bad in your opinion 🙂


bmaptool: info: block map format version 2.0
bmaptool: info: 211529 blocks of size 4096 (826.3 MiB), mapped 211529 blocks (826.3 MiB or 100.0%)
bmaptool: info: copying image ‘ubuntu-touch-pinephone.img.xz’ to block device ‘/dev/mmcblk0’ using bmap file ‘pphone.bmap’
bmaptool: WARNING: failed to enable I/O optimization, expect suboptimal speed (reason: cannot switch to the ‘noop’ I/O scheduler: [Errno 22] Invalid argument)
bmaptool: info: 100% copied

bmaptool: ERROR: checksum mismatch for blocks range 0-211528: calculated 92c113dde2f5836ccdfc756c2713965bcbd49e5fd9208f0ff89bba4df904f3e2, should be e8648c7193ae920c23de5dcbb23be9ecdca0c94dbfd16b4c003ec9f0511e4406 (image file /home/wt/Downloads/ubuntu-touch-pinephone.img.xz)


Well hopefully this blog was good payback for the nice guy who recommended it. Definitely it’s a time saver and ‘not so hard’ if you have some instruction.

Categories
Tutorial Ubuntu Ubuntu Touch

Flashing Ubuntu Touch onto SD Card for Pinephone Braveheart Installation

EDIT 20/06/19
I have done a fairly extensive post about how to use BMAP properly so here is a link to my post. You should probably read this to know that the true benefits of speed from Bmap tools comes from following the instructions in my other blog. Otherwise, you might as well just use ‘dd’ or other flashing techniques. Bmap is indeed faster!

EDIT: 20/06/14

I tried with Etcher and had problems booting (not sure this was actually the cause) so now I’m trying with a tool recommended bmap-tools by someone in the Pinephone Telegram group. This tutorial includes instructions for getting set up and using this bmap tools tool.

This tutorial assumes you are running Ubuntu on your desktop/pc/laptop…

It’s a command line tool, it seems so yeah. No GUI. Hopefully my commands and instructions will remove the CLI mystique…

Apparently bmap-tools also automatically unzips/uncompresses your ubuntu-touch-pinephone.img.xz image as well, so you don’t have to do that step before.

  1. Get Ubuntu Touch image currently here
  2. Install to ubuntu: sudo apt install bmap-tools
  3. Confirm the source of your ubuntu-touch-pinephone.img.xz file which you have on your computer from this instructional page your source and destination addresses. In my case it’s coming from my download directory and going to my SD card so my source location looks like this:

~/Downloads/ubuntu-touch-pinephone.img.xz

  1. Confirm the destination path of your SD card. This step is important because if you goof this you risk (probably) writing your image to the wrong drive and killing it. How I do this is
    a) Hit the super key to the left of the space bar
    b) Type ‘disks’ to open the Disks utility
    c) Click my SD card on the left pane (graphically)
    d) Take the path from the ‘Device’ path. In my case it looks like this “Device dev/mmcblk0p1” You can actually just highlight it and copy it from there
  • path: /dev/mmcblk0

Important note on this last step: I had a lot of annoyances in the terminal related to ‘memory errors’ and it was because I had copied the entire item. In my case it looked like this: mmcblk0p1. Make sure that you do not have anything like ‘p1’ or ‘p2’ on the end of your destination path. These are for ‘partitions’ and is the incorrect path. should be just : /dev/mmcblk0not something like this –> /dev/mmcblk0p1. If you run it with the latter you will get those memory errors like me.

Just to leave it as reference the errors caused by the mistake above look like this:

bmaptool: info: no bmap given, copy entire image to '/dev/mmcblk0'
bmaptool: WARNING: failed to enable I/O optimization, expect suboptimal speed (reason: cannot switch to the 'noop' I/O scheduler: [Errno 22] Invalid argument)
/
bmaptool: info: synchronizing '/dev/mmcblk0'
bmaptool: info: copying time: 17m 13.1s, copying speed 13.5 MiB/sec
  1. Run the command
    Pre-cautionary step 1: remove all external drives before doing any of this.
    Pre-cautionary step 2: Other tutorials I read did not explain that you should unmount your drive before beginning. So in your Nautilus just go through and ‘eject’ anything showing up as ‘ejectable’.

As a reference, this tutorial was helpful for tool usage but still not quite clear enough so I’ll go even slower…

EDIT 20/06/14 – Apparently this next bit of my advice is bad and slows down the process. Apparently you should just make sure you run the command in the same directory as the image, and then it will work faster and without the need for the –nobmap tag. I will leave this here as a reference just in case you need it but as of today it was advised to not follow it:

—-

With bmaptool when you are doing straight flashing you can just add the --nobmap tag to the command, which I think means ‘just do this thing without routing through other specific instruction file’. So that’s what I’m going to do.

—-

I am still not 100% sure if this step is required, but it helped me so I’m leaving it as a reference: I also got some ‘no space left on device’ errors so I decided to first format the drive with Disk tools before trying again. I did this by opening the ‘Disks’ graphical utility again by clicking the SD card I wanted to format and then selecting ‘format disk’ from the top right hamburger menu. Takes about 2 seconds to wipe whatever is on there… after doing this step everything finally started working better. I created a linux ext4 partition next to see if that helped. I made the first partition with 21GB (for the image) and then a trailing 10GB for ‘whatever’. These were just choices I made thinking that I could maybe use the trailing 10GB for phone storage.

Here are, therefore, the steps, assuming you have done all of the above:

  1. Open the terminal
  2. Make sure you have navigated (with terminal commands) to the directory where your image is
  3. Type the following command replacing the source and path with whatever is correct from your device as per instructions above:

bmaptool -E copy /path/to/ubuntu-touch-pinephone.img.xz /path/to/SD/card

My example that finally worked looked like this for your reference:

sudo -E bmaptool copy ~/Downloads/ubuntu-touch-pinephone.img.xz /dev/mmcblk0

Boot it

Apparently just inserting the SD card and turning the power on should do it, but yeah. Depends on a ‘few things’ as to whether this will be your experience 😉

This was actually harder than I thought. I’m not sure if this was the cause of my pain but I’m going to list it anyways. I had to do about 100 reboots and it still wasn’t working. I couldn’t seem to get past the ubuntu purple splash startup screen. I ‘think’ I had interrupted a process the first time so i did all of the above steps againb but this time I held down the power button until the green indicator light came on and then everything started as expected and I was able to start using Ubuntu Touch. Members of the community indicated it may be related to a faulty build and to try other build numbers to see if that helps. We shall see.

Issues flashing cards

I had an interesting issue where I couldn’t unmount a card. System said ‘not mounted’ when I tried umount command. Amazingly, just a reboot of computer allowed the ‘Disks’ utility to start working again as normal. Others were reporting that one should consider using gparted tools instead of Disks utility just as another related tip if you are interested.

I hope this helps and have a great day

Resources

Pinephone images for Ubuntu Touch here

How to telnet into the device here

My bmap tools tutorial here