Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm would like to open an SSH connection between my local machine and an EC2 instance.

I added my local IP (static) with this port to the 'Groups Permissions' but it doesn't work yet.

When I do: ssh -i .ssh/my_key.pem ubuntu@server_ip -p 8867 It's telling me ssh: connect to host <server_ip> port 8867: Connection refused.

Am I forgetting something?

share|improve this question
Is your EC2 instance definitely listening on that port? – Flup Jun 17 '13 at 15:40
No it's not (see answer below). I don't know how to do it. – Guilhem Soulas Jun 17 '13 at 16:30
up vote 4 down vote accepted

Check that the server is listening on port 8867 using netstat

netatat -tunlp | grep 8867
tcp        0      0*          LISTEN      1425/sshd

If it's not then take the necessary steps to start it. If it is listening then you may need to open port 8867 on the Ubuntu firewall.

Update based on the comments

To have sshd listen on port 8867 you will need to edit /etc/ssh/sshd_config and add a Port statement.

Port 8867

Note that sshd will listen on port 22 by default so if you want sshd to listen on port 8867 as well as port then you need 2 Port statements.

Port 22
Port 8867

You should probably take a look at the documentation too sshd and sshd_config.

share|improve this answer
netstat is not showing my port. How do I tell my server to listen to it? – Guilhem Soulas Jun 17 '13 at 16:28
@GuilhemSoulas: see my update. – Iain Jun 17 '13 at 17:20
Thanks @lain it worked! It may look like a stupid question but everyone has to start from the beginning. – Guilhem Soulas Jun 17 '13 at 17:43
@GuilhemSoulas: You didn't start at the beginning - you jumped right in but forgot about reading documentation ;). – Iain Jun 17 '13 at 17:45

Your Answer


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.