Bookmark this to keep an eye on my project updates!
non root
user on docker host and enable ssh accessI donโt want to have to work with the root user on my Docker host. For this reason, I always create a dedicated user who must also be authorised for the Docker daemon.
These are the necessary steps:
Add the new user (and give him a proper password):
adduser network
Adding user 'network' ...
Adding new group 'network' (1002) ...
Adding new user 'network' (1002) with group 'network' ...
Creating home directory '/home/network' ...
Copying files from '/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for network
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
Add the newly created user to the sudo
group:
usermod -aG sudo docker network
Verify the group memberships of the network
user:
groups network
network : network sudo
Switch to the network
user
su - network
Verify the sudo command:
sudo ls /root
This should work without any errors!
Create a .ssh
folder in the home directory
mkdir ~/.ssh
Edit the ~/.ssh/authorized_keys
file and paste your public SSH key:
nano ~/.ssh/authorized_keys
If you havenโt any SSH keys yet you can easly create on on windows with the ssh-keygen
command:
Secure your ~/.ssh/authorized_keys
file with just owner read/write permissions:
chmod 600 ~/.ssh/authorized_keys
Test the ssh connection from the work computer:
ssh network@docker.local
If you arenโt using your default ssh key for the connection then you have to use the -i
parameter to use the correct private key. e.g.:
ssh -i <path to your private ssh key> network@docker.local
๐๐๐ Mission accomplished ๐๐๐