aeromaxx
Posts: 20
Joined: Sat Jun 11, 2016 11:37 am

adding new users to raspbian stretch lite

Wed Sep 20, 2017 1:33 pm

I'm looking to add a new user to my raspberry pi running raspbian stretch lite.

I followed this guide to attempt to secure my pi, I've only done down to the SSH section and not gone further than that yet.
https://makezine.com/2017/09/07/secure- ... attackers/

I've made some alterations to the following files :-

/etc/bash.bashrc
/etc/screenrc
/home/pi/.bashrc
/etc/skel/.bashrc

When I now login with pi over ssh, I get the following prompt.

Code: Select all

[pi@pi ~]$
When I log with the new user I have created I get the following prompt instead.

Code: Select all

$ 
For the new user $PS1 and $PROMPT_COMMAND are both blank and not set as they should be as specified in the .bashrc file.

The new user's .bashrc file is the same as the pi users .bashrc file.

After making changes I have rebooted, but still the prompt is the same as before.

Edit:

I have found something interesting which is why I now believe that ~/.bashrc isn't being loaded on login.

Code: Select all

[pi@pi ~]$ echo $BASH_VERSION
4.4.12(1)-release
[pi@pi ~]$

Code: Select all

$ echo $BASH_VERSION

$
Last edited by aeromaxx on Wed Sep 20, 2017 5:23 pm, edited 2 times in total.

gkaiseril
Posts: 679
Joined: Mon Aug 08, 2016 9:27 pm
Location: Chicago, IL

Re: adding new users to raspbian stretch lite

Wed Sep 20, 2017 2:58 pm

Within the "/etc" directory there should be a "./skel" directory that is used as a skeleton directory structure when a new user is added. Making changes to the files in this directory should carry over to any new user being added.
f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.

aeromaxx
Posts: 20
Joined: Sat Jun 11, 2016 11:37 am

Re: adding new users to raspbian stretch lite

Wed Sep 20, 2017 3:38 pm

gkaiseril wrote:
Wed Sep 20, 2017 2:58 pm
Within the "/etc" directory there should be a "./skel" directory that is used as a skeleton directory structure when a new user is added. Making changes to the files in this directory should carry over to any new user being added.
I have made the changes to the files in that directory, and the updated files are in the new users home directory, but the prompt isn't the same as the default pi user.

As mentioned the $PS1 and $PROMPT_COMMAND bash variables contain nothing when echo'ed.

The pi user and the newly created user's files in the home directory are identical, but the prompts are different.

sparkyhall
Posts: 166
Joined: Mon Aug 27, 2012 9:14 am

Re: adding new users to raspbian stretch lite

Thu Sep 21, 2017 4:58 pm

It looks like you have not set the default shell for your new user to bash, to do this enter the following:

Code: Select all

sudo usermod -s /bin/bash <your new user name>

aeromaxx
Posts: 20
Joined: Sat Jun 11, 2016 11:37 am

Re: adding new users to raspbian stretch lite

Thu Sep 21, 2017 5:12 pm

sparkyhall wrote:
Thu Sep 21, 2017 4:58 pm
It looks like you have not set the default shell for your new user to bash, to do this enter the following:

Code: Select all

sudo usermod -s /bin/bash <your new user name>
Yes partially correct, for some reason when I created the user, the useradd command didn't create the user with the default shell it should have done according to the /etc/adduser.conf file.

I had thought I had posted this earlier, but just noticed I hadn't clicked submit.

I have worked out what the issue was.

When running a useradd command such as

Code: Select all

useradd "testuser" --groups "sudo" --create-home

The newly created user has no shell, this what is in the /etc/passwd file

Code: Select all

testuser:x:1001:1001::/home/testuser:

When compared with the pi user in the same /etc/passwd file.

Code: Select all

pi:x:1000:1000:,,,:/home/pi:/bin/bash

Also looking at the /etc/adduser.conf file (see below) suggests that the default shell is /bin/bash

Code: Select all

# /etc/adduser.conf: `adduser' configuration.
# See adduser(8) and adduser.conf(5) for full documentation.

# The DSHELL variable specifies the default login shell on your
# system.
DSHELL=/bin/bash

Return to “Advanced users”