LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can not connect to terminal with any user (https://www.linuxquestions.org/questions/linux-newbie-8/can-not-connect-to-terminal-with-any-user-930589/)

mmorto89 02-21-2012 07:07 PM

Can not connect to terminal with any user
 
So I want to use screen to run a program, but I can only connect to the terminal with root. If I try to connect with a user it just keeps saying access is denied. I have setup 1 user and password and I can su to the user but screen wont work that way. I have changed the password multiple times and I know I'm typing the right password in but it still will not let me connect unless I am logging in with root.

Edit: I forgot to add that I am running CentOS 6.

mmorto89 02-21-2012 07:38 PM

Edit: here is the commands I used to make the username "mike"

[root@server ~]# useradd mike
[root@server ~]# passwd mike
Changing password for user mike.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@server ~]#

uhelp 02-21-2012 07:45 PM

Would you please give the commands that you entered?

Your description is misleading.

On the one hand you say you want to use screen on the other you say that you can't connect to terminal.

login with the user name who is running the screen session.
Issue "screen -ls" and you can see how many sreen sessions are running.
If only one is running you can connect to it with "screen -x"
If there are more you have to use the name or pid:name showed by -ls
Something like "screen -x -S name"
or "screen -x -S pid:name"

But I'm not sure whether you are talking from that at all.

mmorto89 02-21-2012 07:51 PM

I'm sorry for being misleading, but my problem is I can only connect to the terminal with root, but I need to connect with my username "mike" to use screen because the program I want to run is in the home directory under that user name. So I can connect to the terminal with root but not "mike". I also know how to use screen. So when I go to the terminal here is what it says.

login as: mike
mike@xxx.141.254.50's password:
Access denied
mike@xxx.141.254.50's password:

but when I login as root it works perfectly fine.

uhelp 02-21-2012 07:56 PM

Well, root can run every programm.
And root can "su mike" without beeing prompted for a password.

something is wrong with the account of "mike".
As root you can can correct this.

Do you use "ssh" to connect to the machine?

"su" stands for SubstituteUser

mmorto89 02-21-2012 08:02 PM

I use the program putty to connect remotely. This is a dedicated server service. I can not run screen when I login as root and and su to mike here is the terminal entry when I do that.


[root@server ~]#
[root@server ~]# su mike
[mike@server root]$ screen
Cannot open your terminal '/dev/pts/0' - please check.
[mike@server root]$

savona 02-21-2012 08:08 PM

When you use putty have you tried to login with mike? What happens.

As root run the following commands and post their output:

cat /etc/passwd

ls -l /home

id mike

mmorto89 02-21-2012 08:12 PM

[root@server ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
avahi:x:70:70:Avahi daemon:/:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:4294967294:4294967294:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
avahi-autoipd:x:100:156:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
webapps:x:500:500::/var/www/html:/bin/false
named:x:25:25:Named:/var/named:/sbin/nologin
diradmin:x:101:157::/usr/local/directadmin:/bin/false
mysql:x:102:158:MySQL server:/var/lib/mysql:/bin/false
majordomo:x:103:2::/etc/virtual/majordomo:/bin/false
dovecot:x:104:104::/home/dovecot:/bin/false
admin:x:501:501::/home/admin:/bin/bash
mike:x:502:503::/home/mike:/bin/bash
gdm:x:42:42::/var/gdm:/sbin/nologin

[root@server ~]# ls -l /home
total 36
drwx--x--x 7 admin admin 4096 Feb 20 20:06 admin
drwxr-xr-x 2 root root 4096 Dec 9 2010 ftp
drwx------ 26 mike mike 4096 Feb 21 18:53 mike
drwx------ 4 503 504 4096 Feb 21 19:35 test
drwxrwxrwt 2 root root 4096 Feb 21 00:10 tmp

[root@server ~]# id mike
uid=502(mike) gid=503(mike) groups=503(mike)

uhelp 02-21-2012 08:13 PM

What is this box running?
Which version?
What services this box offers?


And i would correect the login problem of user mike instead of starting screen.
It is never a good idea to even let root login from remote site.

uhelp 02-21-2012 08:16 PM

Quote:

Originally Posted by mmorto89 (Post 4608773)
[root@server ~]# cat /etc/passwd

operator:x:11:0:operator:/root:/sbin/nologin

???? something seriously damaged?

mmorto89 02-21-2012 08:19 PM

Quote:

Originally Posted by uhelp (Post 4608778)
???? something seriously damaged?

Im not sure? the smiley is from the fourms smiley things, but is that wrong? should it say something else?

uhelp 02-21-2012 08:28 PM

Quote:

Originally Posted by uhelp (Post 4608774)
What is this box running?
Which version?
What services this box offers?

And?

mmorto89 02-21-2012 08:34 PM

Quote:

Originally Posted by uhelp (Post 4608784)
And?

are you asking for the OS on the server? That is centOS 6 sorry i'm not sure what your asking.

uhelp 02-21-2012 08:46 PM

Which services does this machine offer?
It offers a ssh as you log in with Putty, I think.
Is there a web server running?
All kind of servers I'd like to know.

It got a strange layout at /home anyway..

First try to log in as root and change the password for mike
Code:

passwd mike
Then try to log in as mike with the new password.

If it doesn't help, log in again as root and do this:
Code:

cat /etc/pam.d/passwd
and paste the output here.

mmorto89 02-22-2012 06:00 AM

[root@server ~]# cat /etc/pam.d/passwd
#%PAM-1.0
auth include system-auth
account include system-auth
password include system-auth
[root@server ~]#

Changing my password did not work, it still says access is denied when I try to login.

uhelp 02-22-2012 10:44 AM

So the problem seems to be merely a sshd conf issue.

What kind of authentication is this server using?
in other words: what is the __exact__ command Putty uses to log in as root?

And please paste the config of sshd.

It has been working so who or what changed something.
What activities did occur when it stopped working?

mmorto89 02-22-2012 05:59 PM

Quote:

Originally Posted by uhelp (Post 4608796)
Which services does this machine offer?
It offers a ssh as you log in with Putty, I think.
Is there a web server running?
All kind of servers I'd like to know.

It got a strange layout at /home anyway..

First try to log in as root and change the password for mike
Code:

passwd mike
Then try to log in as mike with the new password.

If it doesn't help, log in again as root and do this:
Code:

cat /etc/pam.d/passwd
and paste the output here.

Is this what your looking for?

Code:

[root@server ~]# chkconfig --list
NetworkManager  0:off  1:off  2:off  3:off  4:off  5:off  6:off
acpid          0:off  1:off  2:on    3:on    4:on    5:on    6:off
anacron        0:off  1:off  2:on    3:on    4:on    5:on    6:off
atd            0:off  1:off  2:off  3:on    4:on    5:on    6:off
auditd          0:off  1:off  2:on    3:on    4:on    5:on    6:off
autofs          0:off  1:off  2:off  3:on    4:on    5:on    6:off
avahi-daemon    0:off  1:off  2:off  3:on    4:on    5:on    6:off
avahi-dnsconfd  0:off  1:off  2:off  3:off  4:off  5:off  6:off
capi            0:off  1:off  2:off  3:off  4:off  5:off  6:off
conman          0:off  1:off  2:off  3:off  4:off  5:off  6:off
cpuspeed        0:off  1:on    2:on    3:on    4:on    5:on    6:off
crond          0:off  1:off  2:on    3:on    4:on    5:on    6:off
cups            0:off  1:off  2:on    3:on    4:on    5:on    6:off
da-popb4smtp    0:off  1:off  2:on    3:on    4:on    5:on    6:off
directadmin    0:off  1:off  2:on    3:on    4:on    5:on    6:off
dnsmasq        0:off  1:off  2:off  3:off  4:off  5:off  6:off
dovecot        0:off  1:off  2:on    3:on    4:on    5:on    6:off
exim            0:off  1:off  2:on    3:on    4:on    5:on    6:off
firstboot      0:off  1:off  2:off  3:on    4:off  5:on    6:off
gpm            0:off  1:off  2:on    3:on    4:on    5:on    6:off
haldaemon      0:off  1:off  2:off  3:on    4:on    5:on    6:off
hplip          0:off  1:off  2:on    3:on    4:on    5:on    6:off
httpd          0:off  1:off  2:on    3:on    4:on    5:on    6:off
ip6tables      0:off  1:off  2:on    3:on    4:on    5:on    6:off
ipmi            0:off  1:off  2:off  3:off  4:off  5:off  6:off
iptables        0:off  1:off  2:on    3:on    4:on    5:on    6:off
irda            0:off  1:off  2:off  3:off  4:off  5:off  6:off
irqbalance      0:off  1:off  2:on    3:on    4:on    5:on    6:off
iscsi          0:off  1:off  2:off  3:on    4:on    5:on    6:off
iscsid          0:off  1:off  2:off  3:on    4:on    5:on    6:off
isdn            0:off  1:off  2:on    3:on    4:on    5:on    6:off
jexec          0:on    1:on    2:on    3:on    4:on    5:on    6:on
kdump          0:off  1:off  2:off  3:off  4:off  5:off  6:off
kudzu          0:off  1:off  2:off  3:on    4:on    5:on    6:off
lisa            0:off  1:off  2:off  3:off  4:off  5:off  6:off
lm_sensors      0:off  1:off  2:on    3:on    4:on    5:on    6:off
lvm2-monitor    0:off  1:on    2:on    3:on    4:on    5:on    6:off
mcstrans        0:off  1:off  2:on    3:on    4:on    5:on    6:off
mdmonitor      0:off  1:off  2:on    3:on    4:on    5:on    6:off
mdmpd          0:off  1:off  2:off  3:off  4:off  5:off  6:off
messagebus      0:off  1:off  2:off  3:on    4:on    5:on    6:off
multipathd      0:off  1:off  2:off  3:off  4:off  5:off  6:off
mysqld          0:off  1:off  2:on    3:on    4:on    5:on    6:off
named          0:off  1:off  2:off  3:off  4:off  5:off  6:off
netconsole      0:off  1:off  2:off  3:off  4:off  5:off  6:off
netfs          0:off  1:off  2:off  3:on    4:on    5:on    6:off
netplugd        0:off  1:off  2:off  3:off  4:off  5:off  6:off
network        0:off  1:off  2:on    3:on    4:on    5:on    6:off
nfs            0:off  1:off  2:off  3:off  4:off  5:off  6:off
nfslock        0:off  1:off  2:off  3:on    4:on    5:on    6:off
nscd            0:off  1:off  2:off  3:off  4:off  5:off  6:off
ntpd            0:off  1:off  2:off  3:off  4:off  5:off  6:off
oddjobd        0:off  1:off  2:off  3:off  4:off  5:off  6:off
pcscd          0:off  1:off  2:on    3:on    4:on    5:on    6:off
portmap        0:off  1:off  2:off  3:on    4:on    5:on    6:off
proftpd        0:off  1:off  2:off  3:on    4:on    5:on    6:off
psacct          0:off  1:off  2:off  3:off  4:off  5:off  6:off
rawdevices      0:off  1:off  2:off  3:on    4:on    5:on    6:off
rdisc          0:off  1:off  2:off  3:off  4:off  5:off  6:off
readahead_early 0:off  1:off  2:on    3:on    4:on    5:on    6:off
readahead_later 0:off  1:off  2:off  3:off  4:off  5:on    6:off
restorecond    0:off  1:off  2:on    3:on    4:on    5:on    6:off
rpcgssd        0:off  1:off  2:off  3:on    4:on    5:on    6:off
rpcidmapd      0:off  1:off  2:off  3:on    4:on    5:on    6:off
rpcsvcgssd      0:off  1:off  2:off  3:off  4:off  5:off  6:off
saslauthd      0:off  1:off  2:off  3:off  4:off  5:off  6:off
setroubleshoot  0:off  1:off  2:off  3:on    4:on    5:on    6:off
smartd          0:off  1:off  2:on    3:on    4:on    5:on    6:off
smb            0:off  1:off  2:off  3:off  4:off  5:off  6:off
sshd            0:off  1:off  2:on    3:on    4:on    5:on    6:off
startips        0:off  1:off  2:on    3:on    4:on    5:on    6:off
svnserve        0:off  1:off  2:off  3:off  4:off  5:off  6:off
syslog          0:off  1:off  2:on    3:on    4:on    5:on    6:off
vncserver      0:off  1:off  2:off  3:off  4:off  5:off  6:off
wdaemon        0:off  1:off  2:off  3:off  4:off  5:off  6:off
winbind        0:off  1:off  2:off  3:off  4:off  5:off  6:off
wpa_supplicant  0:off  1:off  2:off  3:off  4:off  5:off  6:off
xfs            0:off  1:off  2:on    3:on    4:on    5:on    6:off
ypbind          0:off  1:off  2:off  3:off  4:off  5:off  6:off
yum-updatesd    0:off  1:off  2:on    3:on    4:on    5:on    6:off
[root@server ~]#


mmorto89 02-22-2012 06:15 PM

Quote:

Originally Posted by uhelp (Post 4609294)
So the problem seems to be merely a sshd conf issue.

What kind of authentication is this server using?
in other words: what is the __exact__ command Putty uses to log in as root?

And please paste the config of sshd.

It has been working so who or what changed something.
What activities did occur when it stopped working?

I don't know what command putty uses to login?

How do I view the sshd config?

I have only had the server for a dew days and the server service setup everything up except the vnc server I did that. As long as I had the server I've had this issue.

savona 02-22-2012 07:10 PM

Quote:

Originally Posted by mmorto89 (Post 4609639)
I don't know what command putty uses to login?

How do I view the sshd config?

I have only had the server for a dew days and the server service setup everything up except the vnc server I did that. As long as I had the server I've had this issue.

to view the sshd config:

cat /etc/ssh/sshd_config

mmorto89 02-22-2012 07:13 PM

Code:

[root@server ~]# cat /etc/ssh/sshd_config
#      $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile    .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication mechanism.
# Depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem      sftp    /usr/libexec/openssh/sftp-server
AllowUsers root
AllowUsers admin
[root@server ~]#


mmorto89 02-22-2012 08:03 PM

So this server has a control panel called directadmin. I've never used a control panel before and could this be the reason why I've been having so many issues with my users?

savona 02-22-2012 08:12 PM

Edit the /etc/ssh/sshd_config file and add:

AllowUsers mike

Also, you should not allow root to log in via ssh, to stop it (ONLY IF MIKE WORKS) change this line:


#PermitRootLogin yes

to

PermitRootLogin no

---------- Post added 02-22-12 at 09:13 PM ----------

Quote:

Originally Posted by mmorto89 (Post 4609689)
So this server has a control panel called directadmin. I've never used a control panel before and could this be the reason why I've been having so many issues with my users?

I am not familiar with directadmin, but there is a user called admin thats allows to log in via SSH.

AllowUsers admin

Also, there is a user called "admin" in your /etc/passwd file. The UID is 501 so it was the first user created (after root):

admin:x:501:501::/home/admin:/bin/bash

mmorto89 02-22-2012 08:15 PM

Quote:

Originally Posted by savona (Post 4609694)
Edit the /etc/ssh/sshd_config file and add:

AllowUsers mike

Also, you should not allow root to log in via ssh, to stop it (ONLY IF MIKE WORKS) change this line:


#PermitRootLogin yes

to

PermitRootLogin no

---------- Post added 02-22-12 at 09:13 PM ----------



I am not familiar with directadmin, but there is a user called admin thats allows to log in via SSH.

AllowUsers admin

Well I think I use ssh to login to my terminal, so how would I get root access if I needed it?
and the username admin also does not work I already tried to login to that user and I changed the password for admin and still nothing.

mmorto89 02-22-2012 08:17 PM

OH MY!!! IT WORKS!!! finnaly!!! thank you so much! but I'm still curious about my question above how would I get root access if I disable ssh for root?

EDIT: oh and I guess I was just putting the wrong password in for admin because it worked right after I changed it.

savona 02-22-2012 08:36 PM

Disabling SSH for root just means root can not log in "remotely". Once you log in as Mike you can use the following command to "become" root.

su -

You will be prompted for the root password after issuing the above command.

mmorto89 02-23-2012 02:45 AM

Quote:

Originally Posted by savona (Post 4609708)
Disabling SSH for root just means root can not log in "remotely". Once you log in as Mike you can use the following command to "become" root.

su -

You will be prompted for the root password after issuing the above command.

Oh I wasn't sure if that would work. Thanks for the great advice and helping me fix that.

EDDY1 02-23-2012 02:53 AM

I'm not sure if this helps but I believe it was the original problem.
I hope I read this right.
http://www.cyberciti.biz/tips/linux-...to-system.html

buenasolas 08-24-2012 04:14 PM

Wow, late to the party, but I figured I'd comment on this. I was looking at your useradd commands, and it appears that you might not have created a home directory for your user. Can you verify if a user directory was created in /home(or wherever you have home directories). useradd -m $USERNAME will create a new account AND a new home directory for that user in the default location. This may be related to your problem(but you probably already have it figured out by now).

EDDY1 08-25-2012 12:14 AM

Quote:

Originally Posted by buenasolas (Post 4763461)
Wow, late to the party, but I figured I'd comment on this. I was looking at your useradd commands, and it appears that you might not have created a home directory for your user. Can you verify if a user directory was created in /home(or wherever you have home directories). useradd -m $USERNAME will create a new account AND a new home directory for that user in the default location. This may be related to your problem(but you probably already have it figured out by now).

OP wasn't in ssh group I'm pretty sure of that.


All times are GMT -5. The time now is 11:13 PM.