How to get Kali tools and Snap on a Chromebook
Tags: chromebook, kali, snap, linux
Published: 2022-03-10 15:34:24

# Introduction

Google has shipped (let's call it reasonable) support for Linux inside a container - [official documentation](https://support.google.com/chromebook/answer/9145439).

I'll walk through how to set up Linux, add the [Kali aptitude repo](https://www.kali.org/docs/general-use/kali-linux-sources-list-repositories/) as well as [Snap](https://snapcraft.io/store). This will get you up and running with your favourite tools.

You will **not** have a Kali desktop UI at the end of this tutorial, just access to the CLI tools, and Snap-based UI applications.

# Enable Linux

## Installing

Hit Search and type "Terminal".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70orqz1hyvcfj76cr4r5.png)
 
This will bring up the "Set up linux development environment" wizard, which is also accessible through Settings.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/naavl7c1yh37beusaqv5.png)

Choose a username.

You can safely go with the recommended size of 10 GB, which can be easily resized later if you need more - or less - space.

Hit Next and wait a couple of minutes.

This will prepare a Debian Buster system in a virtualized container.

It will then open the Terminal app. Right-click it and Pin it to your taskbar for easy access, which you'll need later.

## Customising your System

If you don't like the default hostname "penguin" you can change it. My Chromebook is silver in colour, and I'm French-speaking, so I decided to call mine "argent".

Modify the `/etc/hostname` file, replacing `penguin` with your preferred hostname.

Then, modify the first line of `/etc/hosts` to match, and leave the rest as they are. In my case:

```
127.0.1.1       argent
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
```

Now, instead of rebooting, right-click the Terminal in the taskbar and choose `Shut down Linux`. Then again to start it.

`shutdown` and `reboot` do not work as expected in this Linux subsystem; don't use them.

# Adding Kali Aptitude Repos

Next, we'll add the [Kali apt repos](https://www.kali.org/docs/general-use/kali-linux-sources-list-repositories/) and the public GPG key:

```bash
echo "deb http://http.kali.org/kali kali-rolling main contrib non-free" | sudo tee /etc/apt/sources.list.d/kali.list

wget -q -O - https://archive.kali.org/archive-key.asc | sudo tee /etc/apt/trusted.gpg.d/kali-rolling-repo.asc
```

<u>Note</u>: You may see references elsewhere to `apt-key add`. This feature was deprecated yesterday, the above method is preferred.

Update your local aptitude cache:

```bash
sudo apt update

Get:1 http://kali.download/kali kali-rolling InRelease [30.6 kB]
Get:2 http://kali.download/kali kali-rolling/main amd64 Packages [18.0 MB]                  
Ign:3 https://storage.googleapis.com/cros-packages/99 bullseye InRelease
Hit:4 https://storage.googleapis.com/cros-packages/99 bullseye Release
Get:6 http://kali.download/kali kali-rolling/contrib amd64 Packages [113 kB]
Get:7 http://kali.download/kali kali-rolling/non-free amd64 Packages [194 kB]
Fetched 18.3 MB in 3s (5,779 kB/s)                       
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

347 packages can be upgraded. Run 'apt list --upgradable' to see them.
```

And update everything, clean and remove redundancies:

```bash
sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y
```

This took around 4 minutes on my N6000.

Restart the Linux system by right-clicking Terminal and choosing `Shut down Linux`. Click to start it again.

# Snap

## What is [Snap](https://snapcraft.io/)?

> Snaps are app packages for desktop, cloud and IoT that are easy to install, secure, cross‐platform and dependency‐free. Snaps are discoverable and installable from the Snap Store.

You can snap-in lots of great applications with a single command, like [JetBrains IDEs](https://snapcraft.io/publisher/jetbrains), [VS Code](https://snapcraft.io/code), [Firefox](https://snapcraft.io/firefox), [LibreOffice](https://snapcraft.io/libreoffice), and heck, even [PowerShell](https://snapcraft.io/powershell)!

## Installing Snap

You need to install a few dependencies, notably the [SquashFS](https://github.com/plougher/squashfs-tools) and [FUSE](https://github.com/libfuse/libfuse), and Snap itself:

```bash
sudo apt install libsquashfuse0 squashfuse fuse snapd
```

If you try to install Snap without Fuse, you'll get this error:

> error: system does not fully support snapd: cannot mount squashfs image using "squashfs": mount:

By default `snapd` will not start automatically when the Linux system is restarted; trying to run `snap` will fail with the following error:

> error: cannot communicate with server: Post http://localhost/v2/snaps/hello-world: dial unix /run/snapd.socket: connect: no such file or directory

The *permanent* fix is to enable the service at startup:

```bash
sudo systemctl enable --now snapd.apparmor
```

## Installing Snaps

Find some snaps from https://snapcraft.io/store and follow the instructions to install them.

## Running Snaps

To run the snap for VS Code, for example:

```bash
snap run code
```

Note that the first time you run a snap it may take a long time to initialize. Subsequent runs will be quick.

# SSH Keys

Might as well generate an SSH key while we're at it. ECDSA with key size of 521 bits is the [currently-recommended standard](https://www.ssh.com/academy/ssh/keygen) but be warned it is not widely adopted:

```bash
ssh-keygen -t ecdsa -b 521
```

Hat-tips:
- https://linuxconfig.org/gui-software-installers-for-kali-linux
- https://forums.kali.org/showthread.php?18079-Public-key-error
- https://medium.com/@jeffrey.cardillo/using-intellij-and-other-linux-apps-on-your-chromebook-51fd7fadb9db