# [OpenSSH] Can't log in with my username. [SOLVED]

## CiScOh4x0r

Hello,

I have a VPS with Gentoo OpenVZ, everything seems to be fine... But with my user account I cannot acces via SSH, it ask me for username and password, and then putty window just do nothing more to close itself.

Is there some configuration I need to write in my: /etc/ssh/sshd_config  file???

I tried this: 

```
AllowUsers myuser
```

 but It does not work...

Regards,Last edited by CiScOh4x0r on Sat Aug 14, 2010 5:08 pm; edited 1 time in total

----------

## lxg

Is it possible that the user doesn't have a normal shell, but something like /bin/false or /bin/nologin?

----------

## CiScOh4x0r

Thank you for your answer I've already check.  

localhost ~ # cat /etc/passwd

```
localhost ~ # cat /etc/passwd

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/bin/false

daemon:x:2:2:daemon:/sbin:/bin/false

adm:x:3:4:adm:/var/adm:/bin/false

lp:x:4:7:lp:/var/spool/lpd:/bin/false

sync:x:5:0:sync:/sbin:/bin/sync

shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

halt:x:7:0:halt:/sbin:/sbin/halt

news:x:9:13:news:/var/spool/news:/bin/false

uucp:x:10:14:uucp:/var/spool/uucp:/bin/false

operator:x:11:0:operator:/root:/bin/bash

portage:x:250:250:portage:/var/tmp/portage:/bin/false

nobody:x:65534:65534:nobody:/var/empty:/bin/false

man:x:13:15:added by portage for man:/usr/share/man:/sbin/nologin

sshd:x:22:22:added by portage for openssh:/var/empty:/sbin/nologin

myusername:x:1000:1000::/home/myusername:/bin/bash

```

myusername:x:1000:1000::/home/myusername:/bin/bash

Could this be the problem?

man:x:13:15:added by portage for man:/usr/share/man:/sbin/nologin

sshd:x:22:22:added by portage for openssh:/var/empty:/sbin/nologin 

----------

## krinn

you may just miss on who you are trying to log in

root> ssh blahblah = will try ssh to blahblah as root

me>ssh blablah = will try to ssh blahblah as me

notme>ssh me@blablah = will try to ssh to blahblah as me

and the rules to access "me" are define in /home/me/.ssh, the rules for your sshd (the server itself) are in /etc/sshd and the rules for root account are in /root/.ssh (but you shouldn't use it)

so if you want to authorize someone for "me" you should put this in /home/me/.ssh/authorized_keys

and the access types (password/nopassword) is set in /etc/ssh/sshd_config, it's explain in the file itself

if you get it, even if you allow anyone to access the account "bob" as long as you don't use ssh bob@blahblah you will try to access the account you're login and this might not do what you wish if you're not login as bob

and next lines are ok (you should trust portage sometimes  :Very Happy:  )

```
man:x:13:15:added by portage for man:/usr/share/man:/sbin/nologin

sshd:x:22:22:added by portage for openssh:/var/empty:/sbin/nologin 
```

----------

## Hu

 *CiScOh4x0r wrote:*   

> putty window just do nothing more to close itself.

 What is the output of ssh -v myusername@myhost?  Are there any useful messages in the system logs?

----------

## CiScOh4x0r

Hello everyone thank you for your answer...

Krinn... But, that isnt if I'm going to access to my server only from one PC? I need and I will access from at least 3 PC, that's why I did not do that...

That should work? Ok, I'm going to try.

Hu,  No useful messafes in the system logs...

I just read something like:  "myusername does not have permission to access" something like that..

By the way, I do not know if this might help, but... I did

```
#visudo

and uncommented this line:

%wheel        ALL=(ALL)       ALL
```

For my username....

Any help? thank you!

----------

## CiScOh4x0r

Hello,

This is the message:

Could not chdir to home directory /home/myusername: Permission denied /bin/bash permission denied

myhost /home/myusername # ls -la  //as root

total 24

drwx------ 3 myusername myusername 4096 Aug 13 19:36 .

drwxr-xr-x 3 root  root  4096 Aug 13 19:36 ..

-rw-r--r-- 1 myusername myusername   127 Aug 13 15:58 .bash_logout

-rw-r--r-- 1 myusername myusername   193 Aug 13 15:58 .bash_profile

-rw-r--r-- 1 myusername myusername  551 Aug 13 15:58 .bashrc

I tried copying .bas_profile to /root and it does not work, nor chmod 700

----------

## Hu

 *CiScOh4x0r wrote:*   

> Hu,  No useful messafes in the system logs...
> 
> I just read something like:  "myusername does not have permission to access" something like that..

 Which is it?  Messages indicating lack of permission are often quite useful.

 *CiScOh4x0r wrote:*   

> By the way, I do not know if this might help, but... I did
> 
> ```
> #visudo
> 
> ...

 Until you reach the point that you have successfully logged in and attempt to use sudo, that change is not relevant to the problem at hand.

 *CiScOh4x0r wrote:*   

> Could not chdir to home directory /home/myusername: Permission denied /bin/bash permission denied

 What is the output of ls -ldn / /bin /bin/bash /home /home/myusername?  I could guess at the probable output based on the error message supplied, but I would like to confirm before asking you to change anything.

 *CiScOh4x0r wrote:*   

> nor chmod 700

 What did you chmod?

----------

## CiScOh4x0r

because I did not notice the message...  :Laughing: 

I did chmod because I was looking in Google for an answer, and there said "chmod 700 that's work" so, I tried, but it does not work.   :Crying or Very sad: 

This is the output

```
myhost ~ # ls -ldn / /bin /bin/bash /home /home/myusername

drwx------ 16    0    0  16384 Aug 13 04:00 /

drwxr-xr-x  2    0    0   4096 Aug 13 17:59 /bin

-rwxr-xr-x  1    0    0 777144 Aug 13 15:58 /bin/bash

drwxr-xr-x  3    0    0   4096 Aug 13 20:29 /home

drwx------  3 1000 1000   4096 Aug 13 19:36 /home/myusername

```

Help? Thank you!

EDIT: I chmod /home/myusername

----------

## lxg

Some other things: are you using SElinux? Can you post the output of mount?

How did you create your user? Can you create another user with the following commands (as root on that machine) and then try to log in with that one from remote?

```
# useradd -m testuser

# passwd testuser
```

Also, when you're root on the machine, what happens when you do this:

```
# su - myusername

$ pwd

$ touch delete_me_later.txt

$ ls

$ logout
```

----------

## CiScOh4x0r

I've created 3 users in that way,  but none works.

And I did:

```
myhost ~ # su - myusername

Unable to cd to '/home/myusername'

```

I don't have selinux..

----------

## lxg

What's the output of the mount command?

----------

## CiScOh4x0r

Sorry,

```
myhost ~ # mount

/dev/simfs on / type simfs (rw)

/proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)

udev on /dev type tmpfs (rw,nosuid)

devpts on /dev/pts type devpts (rw,nosuid,noexec)

shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec)

```

----------

## Hu

 *lxg wrote:*   

> Some other things: ...

 Good thoughts, but he already showed us the problem.

 *CiScOh4x0r wrote:*   

> 
> 
> ```
> myhost ~ # ls -ldn / /bin /bin/bash /home /home/myusername
> 
> ...

 Search permission is required on a directory and all its parent directories.  Setting / to anything other than 755 is likely to cause problems and should only be done if you know exactly why you need to do it.  You have set it to 700, so only root can search any directories.

----------

## CiScOh4x0r

Good one! that is the problem!

Now, It works!

I changed /  to 755 and voola! it works!

Thank you all for your help!  :Razz: 

----------

