LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-04-2019, 11:38 AM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
Cannot login on SSH


I have Linux running on a virtual machine, trying to log in from the host OS:

$ ssh -l root 172.16.33.1
root@172.16.33.1's password:
Permission denied, please try again.
root@172.16.33.1's password:
Permission denied, please try again.
root@172.16.33.1's password:
Permission denied (publickey,password).

Inside the VM:

# cat /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
UseLogin yes

What else is missing?

Last edited by lucmove; 10-04-2019 at 11:40 AM.
 
Old 10-04-2019, 12:46 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by lucmove View Post
I have Linux running on a virtual machine, trying to log in from the host OS:

$ ssh -l root 172.16.33.1
root@172.16.33.1's password:
Permission denied, please try again.
root@172.16.33.1's password:
Permission denied, please try again.
root@172.16.33.1's password:
Permission denied (publickey,password).

Inside the VM:

# cat /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
UseLogin yes

What else is missing?
You don't provide details, such as version/distro of Linux, any firewalls in place between the two, whether the service is actually even started or not, or whether you restarted it to make the changes take effect. Can you even log in as a 'regular' user? Because logging in as root is an INCREDIBLY BAD IDEA, and there's just no need to do it. Log in as a regular user, and use su or sudo as needed.
 
Old 10-04-2019, 03:16 PM   #3
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
I have a firewall that should never block local traffic, but turned it off anyway and it didn't make any difference.

Security is no concern. It's a virtual machine. It's just for tests. I want to log in as root.
 
Old 10-04-2019, 03:20 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by lucmove View Post
I have a firewall that should never block local traffic, but turned it off anyway and it didn't make any difference.
And did you turn off firewalls on BOTH sides? Did you open the port for SSH, because it's blocked by default. And you still haven't answered things asked before, such as version/distro of Linux, did you restart/start the service, etc., nor whether you can log in as a regular user. And now you say it's a VM...can you even ping between the host and guest? Until you answer and provide details, there isn't much anyone can tell you.
Quote:
Security is no concern. It's a virtual machine. It's just for tests. I want to log in as root.
Learn to do things correctly, if you're starting out. No one, anywhere, that does IT professionally, will log in as root. But you've been here FOURTEEN YEARS....should be obvious not to do this, and why.
 
Old 10-04-2019, 04:11 PM   #5
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by TB0ne View Post
And now you say it's a VM...
I said it in the original post.

It's Debian 9. There is no firewall in the guest OS. There is nothing in it. It's just the most basic net install.

Yes, I can ping the guest OS. I can log in through SSH as root inside the VM/guest. I can't log in from the host OS. It can't be firewall related because the error message makes it very clear that the connection is established. It's just that sshd rejects my login attempt. Why? I have checked all sshd_config options. Or have I?
 
Old 10-04-2019, 04:47 PM   #6
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Well, regular user can't log in either. It can from inside the VM itself, but not from outside.
 
Old 10-04-2019, 04:51 PM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by lucmove View Post
Well, regular user can't log in either. It can from inside the VM itself, but not from outside.
There you go.
Did you post your entire sshd_config? Because what you posted doesn't appear to be complete.
Did you confirm that sshd is actually running and listening on the default port?
 
1 members found this post helpful.
Old 10-04-2019, 04:55 PM   #8
erik2282
Member
 
Registered: May 2011
Location: Texas
Distribution: Primarily Deb/Ubuntu, and some CentOS
Posts: 829

Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by lucmove View Post
I can log in through SSH as root inside the VM/guest. I can't log in from the host OS
Are you saying you have 3 machines? 2 physical machines, and 1 of them has a Debian VM? So from the physical machine that doesn't have the VM, you are able to SSH to the VM on the other physical machine? Am I getting that right?

Which VM software are you using? virtualbox? What OS does your host have?
 
Old 10-04-2019, 04:58 PM   #9
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
$ ssh -l nix 172.16.33.1
nix@172.16.33.1's password:
Permission denied, please try again.
nix@172.16.33.1's password:
Permission denied, please try again.
nix@172.16.33.1's password:
Permission denied (publickey,password).

# service ssh status
Click image for larger version

Name:	ssh_status.png
Views:	131
Size:	16.0 KB
ID:	31458

/var/log/syslog
Click image for larger version

Name:	ssh_syslog.png
Views:	101
Size:	27.5 KB
ID:	31459

/var/log/auth
Click image for larger version

Name:	ssh_auth.png
Views:	85
Size:	27.3 KB
ID:	31460
 
Old 10-04-2019, 05:00 PM   #10
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by erik2282 View Post
Are you saying you have 3 machines? 2 physical machines, and 1 of them has a Debian VM? So from the physical machine that doesn't have the VM, you are able to SSH to the VM on the other physical machine? Am I getting that right?

Which VM software are you using? virtualbox? What OS does your host have?
One physical Debian 9 connecting to a virtual Debian 9 inside aforementioned Debian 9 on VMWare.
 
Old 10-05-2019, 12:59 AM   #11
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
I don't understand exactly how I fixed it, but I did.

I ran ifconfig in the VM:

Click image for larger version

Name:	ssh_solved.png
Views:	132
Size:	11.1 KB
ID:	31461

I noticed an IP number in it that I hadn't tried: 172.16.33.146

So I connects to it:

$ ssh -l root 172.16.33.146

It wants to add the new server to ~/.ssh/known_hosts, I accept it, and it works.

Solved. Thank you all.
 
Old 10-05-2019, 10:40 AM   #12
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by lucmove View Post
I don't understand exactly how I fixed it, but I did.

I ran ifconfig in the VM:

Attachment 31461

I noticed an IP number in it that I hadn't tried: 172.16.33.146

So I connects to it:

$ ssh -l root 172.16.33.146

It wants to add the new server to ~/.ssh/known_hosts, I accept it, and it works.

Solved. Thank you all.
Glad you got it worked out. Some thoughts to consider:
You apparently have the networking configured to use DHCP.
You didn't know what the IP address was until you ran ifconfig on the VM.
Once you knew the IP address, then you were able to connect.
Note that you will get the prompt to add the key to known_hosts again if the IP address changes. You will also get that prompt again if you sign in as a different user.
Q: Why did you think the address was 172.16.33.1?
Q: What is actually running on 172.16.33.1? (Since you could connect to that IP, but not login -- the router, perhaps?)
[Those questions are food for thought for you, but it might be helpful to others if you want to share the answers]
 
Old 10-05-2019, 12:03 PM   #13
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by scasey View Post
Q: Why did you think the address was 172.16.33.1?
Q: What is actually running on 172.16.33.1? (Since you could connect to that IP, but not login -- the router, perhaps?)
[Those questions are food for thought for you, but it might be helpful to others if you want to share the answers]
I got that from running ifconfig on the host OS, which gave me that one and another IP number for vmnet1 and vmnet8, respectively. Both failed. It didn't occur to me to run ifconfig on the guest OS until much much later. They pinged and sshd did respond to them, which was confusing as hell. I still don't understand why sshd will respond but forbid access. If at least sshd was unreachable, it would make sense.
 
Old 10-05-2019, 01:17 PM   #14
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Perhaps the passwords are different on the host? The responses you posted indicate an incorrect user or password.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Fast login via ssh / Slow login via login manager with machine in AD-domain c01d Linux - Server 2 03-01-2016 01:52 AM
how to log ssh activity in /var/log/ssh/ssh*.log MrUmunhum Linux - Server 3 11-02-2011 02:25 AM
ssh-agent, ssh-add and ssh-keygen AND CVS raylpc Linux - General 2 11-19-2008 02:50 AM
setting up an ssh soxy or local ssh tunnel from within an ssh soxy Mangenius Linux - Networking 0 03-05-2007 03:15 PM
Passwordless SSH with SSH commercial server and open ssh cereal83 Linux - General 7 04-18-2006 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration