Skip to content

linux

5 posts with the tag “linux”

Installing Microsoft Edit in Debian or Ubuntu based distros

Microsoft Edit provides terminal editing with full mouse and copy-paste support.

???+ note The current version of Edit (1.2.0) is not available via the package manager apt yet. This could change at some point in the future, making for an easier deployment.

Install zstd, needed to decompress the downloaded archive:

Terminal window
sudo apt install zstd

Install the latest Edit version from GitHub for x86_64

Section titled “Install the latest Edit version from GitHub for x86_64”

Download and install the latest release: EDIT_VERSION=$(curl -s “https://api.github.com/repos/microsoft/edit/releases/latest” | grep -Po ‘“tag_name”: “v\K[0-9.]+’) wget -qO edit.tar.zst https://github.com/microsoft/edit/releases/latest/download/edit-$EDIT_VERSION-x86_64-linux-gnu.tar.zst sudo tar xf edit.tar.zst -C /usr/local/bin edit edit –version rm -rf edit.tar.zst

The commands above can be turned into a script for repeat installs.

Mount an SMB share and use iGPU on an unprivileged Debian 12 LXC container in Proxmox

Prerequisites:

Create an unprivileged Debian 12 LXC container.

Inside the LXC container, use the root user to create a non-root user. In this example the user is added to the sudo and docker groups after installing Docker inside the LXC container.

Terminal window
useradd -s /bin/bash -m -G sudo,docker ismael

Change the user password as needed.

Terminal window
su ismael
passwd

This user’s default UID:GID will be 1000:1000. If not, create it with:

Terminal window
useradd ismael -u 1000 -g 1000 -m -s /bin/bash -G sudo,docker

Take note of this UID:GID as it will be used to map the share in Proxmox. The share itself can live on another system; here an unRAID VM on the same host is used.

Create a user that can be mapped from the host to the LXC container. Without this step, the share ends up read-only inside the LXC container.

Proxmox maps the users and groups from the host to the LXC containers starting at UID:GID=100000:100000.

The created ismael user then:

  • Inside the LXC container UID: 1000
  • Inside the host UID: 101000

Create a group on the host with GID=101000 that will own the directory created for the SMB share

Terminal window
groupadd -g 101000 ismael

Create the same user that will be used inside the LXC container but with the right UID:GID combination

Terminal window
useradd ismael -u 101000 -g 101000 -m -s /bin/bash

Make a directory for the share

Terminal window
mkdir /mnt/media

Change the directory’s owner to the previously created user

Terminal window
chown ismael:ismael /mnt/media

Modify the /etc/fstab file to mount the SMB share on the directory we created

Terminal window
nano /etc/fstab

Copy this line inside the nano editor for /etc/fstab (note the guest part, as this SMB share has no password set)

Terminal window
//192.168.0.10/media /mnt/media cifs guest,rw,uid=1000,gid=1000,file_mode=0777,dir_mode=0777 0 0

For shares that require a password:

Terminal window
//192.168.0.10/media /mnt/media cifs username=<username>,password=<password>,rw,uid=1000,gid=1000,file_mode=0777,dir_mode=0777 0 0

Reload the changes to /etc/fstab before mounting

Terminal window
systemctl daemon-reload
mount -a

Create a mountpoint in your LXC container pointing to the created share directory

Terminal window
pct set 104 -mp0 /mnt/media,mp=/mnt/user/media

Start the LXC container and the share is mounted in /mnt/user/media, writable by the mapped user.

Coming soon…

Proxmox | automatically restore SMB/CIFS share connections

If at some point Proxmox loses connectivity with an SMB/CIFS share, it will not restore the connection by itself until a restart of the Proxmox node is performed. With the script below, the Proxmox node restores the connection automatically.

On the node’s shell, create a bash script that looks for mount points in /mnt/pve/ and unmounts them if they become stale:

Terminal window
nano remount.sh

Put this content into the file:

#!/bin/bash
list=$(ls /mnt/pve)
for i in $list
do
status=$(ls /mnt/pve/$i 2>&1)
if [[ $status =~ .*Stale.* ]]
then
umount /mnt/pve/$i
fi
done

Remember to make the script executable by the user creating it:

Terminal window
chmod 766 /root/remount.sh

Add a cron job for this script to run automatically:

Terminal window
* * * * * /root/remount.sh >/dev/null 2>&1

With that, any SMB/CIFS connections are restored automatically. That is because the service pvestatd tries to remount every SMB share every 10 seconds.

This approach could work for NFS shares too, but that possibility has not been tested.

Set up your SSH key-based authentication from Windows in a single line

Linux-to-Linux SSH setups are straightforward, but the Windows OpenSSH client needs a different approach to copy a generated key for password-less logins.

Generate your private and public keys in your Windows PowerShell shell

Section titled “Generate your private and public keys in your Windows PowerShell shell”

Execute the command below in Windows Terminal or any other terminal in Windows:

Terminal window
ssh-keygen

This generates the keys in the local host’s Windows profile directory under the .ssh/ sub-directory.

You can access it in this location on Windows by using the key combination Win + R and then entering this text in the Run window:

Terminal window
%userprofile%/.ssh/

That directory will include:

  • your generated private key id_rsa
  • your generated public key id_rsa.pub

The public key is the one we’ll copy into any remote host we want to connect without using a password.

The command below performs the equivalent of ssh-copy-id using the OpenSSH client on Windows. Edit user@host.address with the remote user and host IP/hostname.

Terminal window
type .ssh\id_rsa.pub | ssh user@host.address "mkdir -p .ssh && cat >> .ssh/authorized_keys"

This makes it possible to login directly to your remote host by simply using:

Terminal window
ssh user@host

Password-less login is now available:

SSH tunneling for access to web-based apps on servers

SSH local port forwarding exposes a web UI from a remote server on the local machine. This is useful for tools such as Portainer running on a cloud VM.

Run this command on the local machine:

Terminal window
ssh -L 9000:127.0.0.1:9000 my_user@my-remote-server

This forwards the remote port 9000 to the local machine:

http://localhost:9000 or http://127.0.0.1:9000

At this local address, the Portainer web UI from the remote server is available.