PDA

View Full Version : Unable to login as nonroot user. Remote SSH login works just fine.



Podranok
2020-02-17, 11:00
root@kali:~# whoami
root
root@kali:~# ssh [email protected]
[email protected]'s password:
Linux kali 5.3.0-kali2-amd64 #1 SMP Debian 5.3.9-3kali1 (2019-11-20) x86_64


The programs included with the Kali GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.


Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Feb 17 12:58:42 2020 from 10.10.10.10
dude@kali:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.10.2 netmask 255.255.255.0 broadcast 10.10.10.255

root@kali:~# hostnamectl
Static hostname: kali
Icon name: computer-vm
Chassis: vm
Machine ID: 338a1d7d7a4f4f78927a994865eee4aa
Boot ID: 6be3bd3d3fa944f1a17c4c7c7bd8c8e4
Virtualization: vmware
Operating System: Kali GNU/Linux Rolling
Kernel: Linux 5.3.0-kali2-amd64
Architecture: x86-64



Hello! Please help me to resolve this problem. I'm quite a noob in linux :(
User was added via useradd command. So i'm unable to login using GUI as i do as @root. When i enter login and password for GUI seems linux accept them but instead to load desktop it becomes black for a second and force me back to login screen again.
apt-get update'ed, rebooted. Same thing.

buglab
2020-02-17, 21:00
User was added via useradd command. So i'm unable to login using GUI as i do as @root. When i enter login and password for GUI seems linux accept them but instead to load desktop it becomes black for a second and force me back to login screen again.

There are two ways to add a user: useradd and adduser. The former, which you used, does do some things, like creating a line in /etc/passwd:


$ sudo useradd testme
$ grep testme /etc/passwd
testme:x:1001:1001::/home/testme:/bin/sh

But even though it creates the user, it doesn't do other helpful things like create a user directory.


$ ls /home
kali

My guess is that you can't log in locally because your GUI wants to be able to write into the home directory which doesn't exist. You should be using adduser instead, which will do things like create the user directory in /home and provide a password to the newly-created user.

More info at this StackExchange answer (https://askubuntu.com/a/345986).

Podranok
2020-02-18, 08:19
Hi Buglab! I did as you suggested(deleted user and added it again via adduser but it doesn't help). The result is the same: can login via ssh, can't do it via GUI. I've noticed warning about home directory rights. Could it be the reason? How can i fix that please?

root@kali:~# adduser dude
Adding user `dude' ...
Adding new group `dude' (1000) ...
Adding new user `dude' (1000) with group `dude' ...
The home directory `/home/dude' already exists. Not copying from `/etc/skel'.
adduser: Warning: The home directory `/home/dude' does not belong to the user you are currently creating.
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for dude
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] y
root@kali:~#

Podranok
2020-02-18, 09:00
root@kali:/# cd /home
root@kali:/home# ls -l
total 4
drwxr-xr-x 2 root root 4096 Feb 17 12:45 dude
root@kali:/home# chmod 777 dude
root@kali:/home# ls -l
total 4
drwxrwxrwx 2 root root 4096 Feb 17 12:45 dude
root@kali:/home#

I've changed rights on /home/dude directory and GUI allows user Dude to login. Hands down!
Thx all, topic can be closed.

buglab
2020-02-19, 22:23
Glad you got it working. However, from a security perspective, having your home directory writeable by anyone on the system is not a good idea.

The real problem with your setup is that the home directory "dude" is owned by root. If it were owned by "dude", as it should be, then the original permissions of 755 would be sufficient. So try `sudo chown dude:dude /home/dude` and then set the permissions back to 755.

Podranok
2020-02-21, 15:11
Yeah i know about security issue but it's just a Virtual Lab.