Here's a detailed guide on using SSH with TrueNAS and setting up a user (userxexample). This example assumes that the $HOME variable is not configured for the user.
Title: Setting Up SSH for a User on TrueNAS (userxexample)
Introduction
In this guide, we will walk you through the process of setting up SSH for a user on TrueNAS. We will use the example user userxexample. If the $HOME variable is not configured for this user, we will show you how to set it.
Prerequisites
- Access to the TrueNAS web interface
- Root or administrative access to TrueNAS
Steps
-
Log in to the TrueNAS web interface
Navigate to your TrueNAS web interface using a web browser. The default IP address is
192.168.1.xx. Replacexxwith your TrueNAS IP address. -
Create a new user
- Go to
System > Users - Click on
Add User - Fill in the necessary details:
- Username:
userxexample - Password: Set a strong password
- Home Directory:
/mnt/data0/etc/passwd(or any other directory you prefer) - UID: Leave it as
1000or a higher number - GID: Leave it as
100or a higher number
- Username:
- Click on
Save
- Go to
-
Edit the new user
- Go to
System > Users - Find the newly created user
userxexample - Click on
Edit - Scroll down to the
Shellfield - Change the shell to
/usr/local/sbin/nologin(this will prevent the user from logging in via the console) - Click on
Save
- Go to
-
Install OpenSSH
- Go to
System > Software - Search for
openssh - Click on
Install
- Go to
-
Configure SSH for the user
- Open a terminal session (e.g., PuTTY or Terminal)
- Connect to your TrueNAS server using SSH
- Enter the following command to navigate to the user's home directory:
cd /mnt/data0/etc/passwd - Edit the user's passwd file using your preferred text editor (e.g.,
nano,vim):nano userxexample - Locate the
SSH_AUTH_SOCKandSSH_AGENT_PIDlines. If they are not present, add them:SSH_AUTH_SOCK=/var/run/sshd/agent.sock SSH_AGENT_PID=65534 - Save and close the file
-
Test the SSH connection
- Still in the terminal session, try to connect to the server as the new user:
ssh userxexample@<TrueNAS_IP> - You should be prompted for a password
- If the connection is successful, you will be logged in as the new user
- Still in the terminal session, try to connect to the server as the new user:
Summary
In this guide, we showed you how to set up SSH for a user on TrueNAS. We created a new user, installed OpenSSH, and configured SSH for the user by setting up the necessary environment variables in the user's passwd file.
References