1

Goal...

I made a rails app and I want to clone it from git to cpanel. But I got stuck at the ssh login before the cloning step.

How to clone from git https://documentation.cpanel.net/display/CKB/How+to+Host+Git+Repositories+on+a+cPanel+Account#HowtoHostGitRepositoriesonacPanelAccount-Clone

How to access with ssh https://documentation.cpanel.net/display/CKB/How+to+Access+the+Command+Line

Error I got...

ssh: connect to host example.com port 22: Connection refused

Possible solution...

I googled and the most of online answers were to edit the port number in /etc/ssh/sshd_config. However, given myself being a beginner, I don't even know how to edit that file. It would be great if anyone could help me with how to edit the file as well as the original issue in the above. Thanks in advance.

ymatt
  • 27
  • 1
  • 1
  • 7
  • I'm not sure you can deploy a rails app using cpanel. Additionally, you won't have privileges to edit any system configuration. And again, the server may simply be behind a firewall that prevents SSH from the internet. – Trinopoty Apr 11 '18 at 15:37
  • I made sure the service supports rails apps before buying it. How can I solve if it's the firewall issue? – ymatt Apr 12 '18 at 14:44
  • You have to ask the provider for that. They may allow you to connect using SSH from a fixed IP or deny it all together. – Trinopoty Apr 12 '18 at 14:45
  • Thanks, I will ask them. – ymatt Apr 12 '18 at 15:12
  • They said they would support. Thanks a lot! – ymatt Apr 12 '18 at 15:34

2 Answers2

3

In the document „Access with SSH“, there is a Note at the end:

Note:

If you receive an error message that appears similar to the following example, you may not have SSH privileges enabled on the server. ssh: connect to host example.com port 22: Connection refused Contact your hosting provider or system administrator for more information. Because command line access (shell access) has certain security implications, many web hosting providers restrict this access.

There could be a lot of reasons that you get the error message, IMHO, the most possible reason is that the Server is behind a Firewall and the Port 22 for SSH is Not Open to the incoming requests.

motou
  • 726
  • 4
  • 12
  • Thanks for the comment, motou. How can I identify if the reason is what you just mentioned and how do I counter it? This is my first time using a server other than heroku and I have zero idea about this stuff... – ymatt Apr 12 '18 at 14:43
  • I asked the provider and they will support on this issue... thanks a lot – ymatt Apr 12 '18 at 15:34
  • 2
    I had the same "connection refused" style message and in the end it turned out to be the hosting provider preventing ssh access even though ssh was listed in CPanel as a feature. – Jonathan P Oct 31 '19 at 01:52
0

I had the same issue. What worked for me is:

sudo mkdir /var/run/sshd
sudo apt-get install --reinstall openssh-server

I am on Ubunbut 16.04.4. If my answer doesn't work for you, you can try some of the alternative solutions from here: connect to host localhost port 22: Connection refused.

Frida Schenker
  • 1,219
  • 1
  • 9
  • 14