Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am new to ubuntu. Hence please forgive me if the question is too simple.

I have a ubuntu server setup using amazon ec2 instance. I need to connect my desktop (which is also a ubuntu machine) to the ubuntu server using SSH.

I have installed open-ssh in ubuntu server. I need all systems of my network to connect the ubuntu server using SSH (no need to connect through pem or pub keys).

Hence opened SSH port 22 for my static IP in security groups (AWS).

My SSHD-CONFIG file is:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

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

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

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

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

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# 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 and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

Through webmin (Command shell), I have created a new user named 'senthil' and added this new user to 'sudo' group.

sudo adduser -y senthil
sudo adduser senthil sudo

I tried to login using this new user 'senthil' in 'webmin'. I was able to login successfully.

When I tried to connect ubuntu server from my terminal through SSH,

ssh senthil@SERVER_IP

It asked me to enter password. After the password entry, it displayed:

Permission denied, please try again.

On some research I realized that, I need to monitor my server's auth log for this. I got the following error in my auth log (/var/log/auth.log)

Jul  2 09:38:07 ip-192-xx-xx-xxx sshd[3037]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=MY_CLIENT_IP  user=senthil
Jul  2 09:38:09 ip-192-xx-xx-xxx sshd[3037]: Failed password for senthil from MY_CLIENT_IP port 39116 ssh2

When I tried to debug using:

ssh -v senthil@SERVER_IP


    OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to SERVER_IP [SERVER_IP] port 22.
debug1: Connection established.
debug1: identity file {MY-WORKSPACE}/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file {MY-WORKSPACE}/.ssh/id_rsa-cert type -1
debug1: identity file {MY-WORKSPACE}/.ssh/id_dsa type -1
debug1: identity file {MY-WORKSPACE}/.ssh/id_dsa-cert type -1
debug1: identity file {MY-WORKSPACE}/.ssh/id_ecdsa type -1
debug1: identity file {MY-WORKSPACE}/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1 Debian-7ubuntu1
debug1: match: OpenSSH_5.8p1 Debian-7ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA {SERVER_HOST_KEY}
debug1: Host 'SERVER_IP' is known and matches the ECDSA host key.
debug1: Found key in {MY-WORKSPACE}/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password
debug1: Next authentication method: password
senthil@SERVER_IP's password: 
debug1: Authentications that can continue: password
Permission denied, please try again.
senthil@SERVER_IP's password: 

For password, I have entered the same value which I normally use for 'ubuntu' user.

Can anyone please guide me where the issue is and suggest some solution for this issue?

share|improve this question
    
You did set the password for the ubuntu user? And you're sure you're typing it correctly? Also include the output of id ubuntu run from your server in your question. Did you lock the account perhaps? Consider including the output of grep ^ubuntu /etc/passwd /etc/shadow (and change the encrypted password only in the middle of the string). –  gertvdijk Jul 2 '13 at 11:19
    
Actually I haven't created any seperate user for SSH. I have used the user which I normally use for server login. The output of grep ^ubuntu /etc/passwd /etc/shadow is: /etc/passwd:ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash /etc/shadow:ubuntu:!$6$rWDSGDSGhv$WDFDASGFDAG.Pz0ob54/epaDSGDSGQKnKqQMFG..OieFiL‌​UndF6KnSDGHDSGHmTMjAGHDSH214I7FHSi1:15347:0:99999:7::: –  Kamal Jul 2 '13 at 11:22
    
Thanks again for your clear response.. If I need to create separate user for SSH and add that to some SSH config, can you please give me some steps for that. –  Kamal Jul 2 '13 at 11:23
add comment

2 Answers

You've locked the account.

From the manpage of usermod(8):

-L, --lock
           Lock a user's password. This puts a '!' in front of the encrypted password,
           effectively disabling the password.

Now look at your shadow line:

ubuntu:!$6$rWDSG...HSi1:15347:0:99999:7:::

Unlock it:

usermod -U ubuntu

Important note! If this user is preinstalled on the system it may be locked for a reason (security reasons), but I cannot decide that for you since this isn't a regular Ubuntu install apparently.


If the above makes you feel uncomfortable, you could create a separate user:

sudo adduser username

and answer the questions. You should be able to login just fine. Also make it able to become root (use sudo) by adding it to the sudo group:

sudo adduser username sudo

In case you need to switch to the ubuntu user on the command line, you'll have to use your elevated privileges, because you can't provide credentials for the same reason as why you can't log in using SSH. Now, log in using SSH as username, and run this to become ubuntu:

sudo su -l ubuntu

For security reasons I would not advise to use root to log in directly.

share|improve this answer
    
I feel the user 'ubuntu' is locked for security reasons. Or to avoid this confusion, I have also tried to login using my root user account.. I am still getting the same error in terminal and auth.log file. –  Kamal Jul 2 '13 at 11:29
    
You mean the root account? That account doesn't have a password and is locked by default. Have you enabled it? –  Alaa Jul 2 '13 at 11:31
    
@Kamal I've updated my answer to include how to do that. –  gertvdijk Jul 2 '13 at 11:36
    
Thanks gertvdijk. I will try this now. I have also editted my question and updated the output of ssh -v ubuntu@SERVER_IP –  Kamal Jul 2 '13 at 11:40
    
@Alaa: No.. I haven't enabled it. Just tried to login using root.. Currently I am using the user: 'ubuntu' for login (in webmin) –  Kamal Jul 2 '13 at 11:43
show 3 more comments
up vote 0 down vote accepted

I found where the issue is and fixed.

I have created a new user (named: senthil) and just used it for SSH. In Ubuntu, I feel that when we create a new user, by default the root user's password will be assigned to the new user. Even then, reset and assign some new password to the newly created users.

Once after the user password reset and making the following changes in sshd_config, now I am able to connect all my systems (from my network) to remote server.

Please Note: I have switched off all SSH authentications (like RSAAuthentication, PubkeyAuthentication and KerberosAuthentication).. I have turned on only the PasswordAuthentication.

Thank You.

share|improve this answer
    
"I feel that when we create a new user, by default the root user's password will be assigned to the new user." <-- No, you are asked to set a password using adduser. Did you use useradd instead? –  gertvdijk Jul 4 '13 at 19:14
    
I have used the following two commands: "sudo adduser -y senthil" and "sudo adduser senthil sudo". May be as I have created users using webmin commandline, it haven't asked me to enter password during user creation –  Kamal Jul 5 '13 at 6:49
    
gertvdijk, consider that I am having only webmin access for a server. In webmin command line, GUI prompt or the step by step installation is not possible. So I feel that in webmin command line, it haven't asked me to enter password. In such cases what can I do? Is there any other command, other than "sudo adduser -y senthil" such that in ONE COMMAND I will create and assign passwords to users? sorry for the lengthy question. –  Kamal Jul 5 '13 at 6:54
    
But you have console access on an EC2, right? Of course, running these commands via Webmin is VERY limited. Sorry that I wasn't explicit on running this in the console rather than Webmin (this really limits your options/capabilities). –  gertvdijk Jul 5 '13 at 9:14
    
You meant that, you just change the password of that user and everything OK? I have the same problem. In my case all the users include root get that error?! –  shgnInc Dec 1 '13 at 15:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.