Attempts to reproduce a Local Port Forwarding example on 16.04 with the command:

$ ssh -L 8080:www.slashdot.org:80 localhost


ssh: connect to host localhost port 22: Connection refused

The tutorial sets the expectation: You will be prompted to enter your user password for the client machine.

Essentially, you are connecting, via SSH, back to your client machine, but creating the necessary SSH tunnel to the destination. After you've successfully authenticated against your local account, open up a browser and point it to http://localhost:8080. Your browser should automatically redirect you to Slashdot.'

Any insight as to why I am not prompted for my Ubuntu credentials at the command line is appreciated.


$ systemctl status ssh.service


● ssh.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
  • Do you have an SSH server running on localhost? what does systemctl status ssh.service say? – steeldriver Feb 15 at 3:11
  • @steeldriver Thanks for the good question. Results are posted at the OP tail. – gatorback Feb 15 at 3:13
  • OK so it looks like it is not running - and possibly not even installed. Make sure you have done so (ex. sudo apt install openssh-server) – steeldriver Feb 15 at 3:15
  • @steeldriver I was under the (incorrectly) under the impression that an ssh server was running out of the box. Thank you for helping to trouble shoot. If you post as an answer, I will award credit. – gatorback Feb 15 at 3:19
  • Thanks - answer added below – steeldriver Feb 15 at 3:36

In order to use this type of port forwarding, there needs to be an SSH server running on the localhost. The somewhat unspecific error message

ssh: connect to host localhost port 22: Connection refused

may indicate that there isn't (although it can also indicate a problem with configuration or firewalling).

On current (systemd based) Ubuntu systems, you can check if such a server is running using

systemctl status ssh.service

If necessary, install the default OpenSSH server using

sudo apt install openssh-server

(it should start automatically if the install command succeeds).

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.