LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Unable to connect with SSH (https://www.linuxquestions.org/questions/linux-server-73/unable-to-connect-with-ssh-4175680926/)

mallen 08-23-2020 05:09 PM

Unable to connect with SSH
 
I am trying to use the transfer tool in WHM. There was some connection issues. So I tried to SSH into the server to see if it would work. Each time I use Putty it closes immediately after I enter my password. Is there anything I can check on the server to allow me to connect?

I tried using the terminal in WHM and looked at the logs

# tail -f -n 50 /var/log/secure | grep sshd


pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=xxx.xxx.xx.xx user=myname
error: PAM: Authentication failure for myname from xxx.xxx.xx.xx
Accepted keyboard-interactive/pam for myname from xxx.xxx.xx.xx port 58783 ssh2
pam_unix(sshd:session): session opened for user myname by (uid=0)
pam_unix(sshd:session): session closed for user myname

berndbausch 08-23-2020 09:05 PM

I don't know what's WHM. Obviously the ssh client was able to connect to the ssh server, but the server did not accept the password.

The easiest solution is resetting myname's password.

frankbell 08-23-2020 09:50 PM

berndbausch, WHM is likely the Web Host Manager.

OP, does your hosting provider offer tech support? If so, that might be the best place to direct your question.

mallen 08-24-2020 12:03 AM

Web Host Manager, or WHM, is the program that allows administrative access to the back end of cPanel. Unfortunately they don't offer detailed support. Usually when things come up, I have to figure it out and learn. Yes the password has been changed. I have also posted on the cpanel forum but no replies yet.

One thing I noticed was this line in the config file. It doesn't say yes or no because its commented out.

vi /etc/ssh/sshd_config

# Authentication:
#PermitRootLogin yes

My new server that I can log in reads like this:
PermitRootLogin no

berndbausch 08-24-2020 01:47 AM

The sshd_config settings disable/enable root logins, not logins to account myname.

mallen 08-24-2020 08:13 AM

I wasn't sure if that could be the issue. "myname" is the root root/admin/main user of the server. If I purposely enter the wrong password it will say access denied. If I enter it correct the connection is terminated. Maybe I need to fix something in the pam settings?

scasey 08-24-2020 08:34 AM

Commented out entries in sshd_config typically reflect the defaults.

root is the only “root/main/admin” user of the server. Are you trying to connect as root? Or as a regular user?
Obfuscating the IP address makes sense, but we need to know if you’re using root or some other user to connect.

Typically, I will ssh to a remote server as an unprivileged user and su to root if I need to.

mallen 08-24-2020 08:38 AM

I think my username is considered a "super user"? Its the main user for the server. I am not typing "root" when I login using putty. Since I can't get the transfer tool to connect and finish, there must be an issue but I don't know where to look.

boughtonp 08-24-2020 08:43 AM

Quote:

Originally Posted by mallen (Post 6158856)
Each time I use Putty it closes immediately after I enter my password.

In Putty, change "Close window on exit" to "Never" before connecting, then you'll be able to see if there's any diagnostic messages being output.


Turbocapitalist 08-24-2020 08:46 AM

If you can connect to your system on an alternative port, one other than 22, then you can set up a one-off, verbosely logged SSH session there:

Code:

sudo /usr/sbin/sshd -d -d -d -p 2222 -E /tmp/sshd.log
That would allow you to connect once and only once with SSH to port 2222 and all the connection information would be logged to the file there /tmp/sshd.log. Hopefully that would also contain the reason for disconnection, if it pertains to the SSH daemon. If it is a matter of PAM, then it may still provide that much.

See "man sshd" for a more authoritative explanation of those options.

mallen 08-24-2020 10:09 AM

Quote:

Originally Posted by boughtonp (Post 6159100)
In Putty, change "Close window on exit" to "Never" before connecting, then you'll be able to see if there's any diagnostic messages being output.


I changed that setting. Now it says "Putty fatal error. Server unexpectedly closed network connection".
Another thing I noticed, it is not reporting any connections for my usuername but if i enter an incorrect password it will.

I contacted my service provider of my VPS. They recommended repairing or reinstalling SSH. Does that sound like a possible fix?

boughtonp 08-24-2020 01:58 PM

Quote:

Originally Posted by mallen (Post 6159145)
I contacted my service provider of my VPS. They recommended repairing or reinstalling SSH. Does that sound like a possible fix?

It sounds like generic "I don't know what's up" advice to me. It may help or may make things worse.

I don't remember if WHM provides a browser-based SSH interface - if it does, I'd use that to try what Turbocapitalist posted and see if that provides further information.

Or try enabling SSH access for another account in case it's a user-specific issue. (I'm assuming you have enabled and successfully used SSH previously for the account currently having trouble.)

Otherwise, whilst uninstalling SSH, purging all config, then re-installing it *might* solve the issue, it might also screw up the link between it and cPanel/WHM and cause other issues (either now or at the next upgrade).

Your best best is to talk to cPanel Support.

cPanel is a paid product - if you're not paying for it, your hosting provider is - so you might as well take advantage of that to get the advice of those that know the product better than anyone here.


mallen 08-24-2020 02:11 PM

Quote:

Originally Posted by Turbocapitalist (Post 6159101)
If you can connect to your system on an alternative port, one other than 22, then you can set up a one-off, verbosely logged SSH session there:

Code:

sudo /usr/sbin/sshd -d -d -d -p 2222 -E /tmp/sshd.log
That would allow you to connect once and only once with SSH to port 2222 and all the connection information would be logged to the file there /tmp/sshd.log. Hopefully that would also contain the reason for disconnection, if it pertains to the SSH daemon. If it is a matter of PAM, then it may still provide that much.

See "man sshd" for a more authoritative explanation of those options.

I tried it and it said connection refused.

sudo /usr/sbin/sshd -d -d -d -p 2222 -E /tmp/sshd.log
sshd: illegal option -- E
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
usage: sshd [-46DdeiqTt] [-b bits] [-C connection_spec] [-c host_cert_file]
[-f config_file] [-g login_grace_time] [-h host_key_file]
[-k key_gen_time] [-o option] [-p port] [-u len]

scasey 08-24-2020 02:30 PM

Have you ever successfully connected to the server with ssh? With this user - or any user?

mallen 08-24-2020 02:42 PM

Quote:

Originally Posted by scasey (Post 6159250)
Have you ever successfully connected to the server with ssh? With this user - or any user?

Yes I have. I rarely use it. I just need to now because i am transferring servers. Same settings on my new server with Putty and can log in there. So its not a network or firewall issue.


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