1

I got some server space and installed an apache web server w/ firewall using this tutorial but now when I try to ssh to the server I get this error

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to xx.xxx.xxx.xx [xx.xxx.xxx.xx] port 80.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request


debug1: ssh_exchange_identification: Date: Tue, 02 Jul 2019 19:27:18 GMT


debug1: ssh_exchange_identification: Server: Apache/2.4.18 (Ubuntu)


debug1: ssh_exchange_identification: Content-Length: 313


debug1: ssh_exchange_identification: Connection: close


debug1: ssh_exchange_identification: Content-Type: text/html; charset=iso-8859-1


debug1: ssh_exchange_identification:


debug1: ssh_exchange_identification: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

debug1: ssh_exchange_identification: <html><head>

debug1: ssh_exchange_identification: <title>400 Bad Request</title>

debug1: ssh_exchange_identification: </head><body>

debug1: ssh_exchange_identification: <h1>Bad Request</h1>

debug1: ssh_exchange_identification: <p>Your browser sent a request that this server could not understand.<br />

debug1: ssh_exchange_identification: </p>

debug1: ssh_exchange_identification: <hr>

debug1: ssh_exchange_identification: <address>Apache/2.4.18 (Ubuntu) Server at sample.com Port 80</address>

debug1: ssh_exchange_identification: </body></html>

ssh_exchange_identification: Connection closed by remote host

I've tried looking at the ssh_config and sshd_config files using vim scp but all I get are empty files. I have no way of accessing the server at the moment. I do not know what the key_load_public file is or what it's supposed to look like. There are no access keys for the server, just one username and password.

  • 1
    The debug information key_load_public: No such file or directory is normal if you are not using those SSH key pairs for your user. From what I can read in your output, you are attempting to connect to SSH server over port 80. Port 80 is normally used by HTTP server. What port is your SSH hosted on (default is port 22)? – GracefulRestart Jul 2 '19 at 20:56
  • I can't connect on port 22. OpenSSH tries to connect, but it never establishes a connection and eventually it times out. The firewall is set up to only allow traffic from port 80. – SkylarLK9998 Jul 2 '19 at 21:18
1

Based on the comments, it seems like you will have to open up port 22 on the server. Like @GracefulRestart said, port 22 is the default port for SSH. When you try to start an SSH session with port 80 on the server, you are actually connecting to the Apache server, not the SSH server. We know that you are talking to the web server because it actually responded with the HTML for a 404 error page.

To open port 22, you could probably follow step 2 in the tutorial that you referenced, but change the application to OpenSSH instead of Apache. Then confirm by trying to start your SSH session again (on port 22).

Note: If you intend to have the SSH server on the public internet for a while, you may want to consider using a non-standard port for SSH. If you use port 22, you will see login attempts. Also consider disabling root login through SSH and make sure your passwords are up to snuff.

| improve this answer | |
  • How am I supposed to open port 22 when I can't get into the server to change the settings or anything? – SkylarLK9998 Jul 3 '19 at 16:05
  • How did you get in before to change the settings without SSH? Was the port open before and you closed it? I don't know how this server is being hosted, but there may be an alternate way to access a console. – afosbenner Jul 3 '19 at 17:46
  • Before I set up the firewall, I could SSH to port 22 and make changes. The server is hosted on a corporate server owned by the company I work for. I am trying to fix this own my own before going to the people incharge of the server space the server is on. They did tell me when they gave me the server space that I was "responsible for it" meaning locking myself out of it isn't something they'll be too happy about. – SkylarLK9998 Jul 3 '19 at 17:51
  • Understood. Unfortunately, you will probably have to fess up to locking yourself out. The good thing is, you found yourself in this situation while trying to secure the system, so you have that going for you. It may be worth a shot to have the administrator reboot the machine for you, and you can hope that the firewall does not start up after the reboot, in which case you should be able to access it through SSH. If you have to fess up anyway, I would take the opportunity to inquire about an alternative way to access a console for the machine through the hypervisor on which it is hosted. – afosbenner Jul 3 '19 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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