Problem: you have a new Samsung tablet or phone with Linux on Dex and you want to ssh into it from your computer. Why? To work with a better keyboard, to use `rsync`, `scp`, `sftp`, move files over sftp from Ubuntu’s Nautilus, etc.
Solution:
Step 1) Edit /etc/ssh/sshd_config
in Linux on Dex and change:
Port 22
to something above 1024. Example: Port 9022
Uncomment ListenAddress
and make it listen to the IP address of the tablet (use ifconfig
to get it). Example: ListenAddress 192.168.0.100
At the very end of the file: UsePAM no
If you connect to another network you’ll have to change the address for ListenAddress
I suggest these other configurations:
PermitRootLogin No
PubkeyAuthentication yes
PermitEmptyPassword no
PasswordAuthentication no
Step 2) Every time you start the Linux on Dex container, run the command
sudo mkdir /var/run/sshd
Unfortunately this directory doesn’t survive the termination of the container.
It must be owned by root.
Step 3) Change the ownership of the site certificates
sudo chown dextop /etc/ssh/ssh_host_*
Step 4) Start the ssh daemon in a terminal with /usr/sbin/sshd -D
Unfortunately starting it with systemd won’t work (this is a LXD container, not a VM) and starting it with root fails too (same problem)
You can create a bash script for the steps from 2 to 4 and run it
Step 5) Create the directory ~dextop/.ssh
in Linux of Dex
mkdir ~dextop/.ssh
chmod 700 ~dextop/.ssh
Step 6) Create a public/private key pair on your computer. I recommend
ssh-keygen -t ed25519 -f ~/.ssh/linux_on_dex
Step 7) Copy your computer’s ~/.ssh/linux_on_dex.pub
into the ~/.ssh/authorized_keys
in Linux of Dex
Step 8) I recommend to create a ~/.ssh/config
file on your computer with this content:
Host *
Protocol 2
ServerAliveInterval 60
Host linux_on_dex
HostName 192.168.0.100 # the address in your network
User dextop
Port 9022 # the one you choose
PubkeyAuthentication yes
IdentitiesOnly yes
IdentityFile ~/.ssh/linux_on_dex
Step 9) Connect from your computer with ssh linux_on_dex
Enjoy!
I noticed that ssh freezes when the tablet is locked so the screen must be on and unlocked. This is far from ideal. If you know a workaround please add a comment to this post.