Connecting to a Shared Server SSH with a Mac

The Secure SHell (SSH) command line is available through an Apple Macintosh computer using their Terminal program. A private and public key pair is required before you can connect to the server. These instructions are are intended for use with a shared server. Learn more about SSH Hosting.

Generate Key for Shell Access

Login to the cPanel and then go to the SSH/Shell Access icon. Click on it to access section where you can generate the private key.

Click on the button labeled Manage SSH Keys

Click on the button labeled Generate a new key

Type in a password (do NOT use the password generator), then confirm it. Make sure to write down the password you used. Leave the key type at DSA and key size at 1024.

If you are creating a key for the first time, click on the Generate Key button.

You should then see a confirmation that the key was generated. Return to the Manage SSH Keys screen

You should see the Public key AND the Private key generated with the name “id_dsa”. Click on View/Download for the PRIVATE key. This is the key that you will need to load onto your Mac.

Download the file to your Mac client. To make it simple for this tutorial, copy the file to your desktop.

Before we move to the Mac side of things, you should check to see if the PUBLIC key has an authorization status of NOT AUTHORIZED. Click on the Manage Authorization link. This will authorize the key for you! NOTE: If you don’t authorize this key, it doesn’t matter what you do on the Mac side, you won’t be able to login.

The next portion of the process requires that you login to your Mac as an administrator. We will be using the default Terminal program in order to login to SSH using the key that we generated above.

Use Apple Terminal Program to Connect to SSH

Login to your Terminal program. If you don’t know how to do this, go the magnifying glass in the OS toolbar (usually at the top right – this is Spotlight) and type in “terminal”. You should see Terminal appear as an application. Select it and it will launch. Note that if you are not logged into your Mac as the administrator you will not be able to make these changes.

Go to your desktop where you copied the ID_DSA file. The terminal command is: cd desktop

Make sure that the ID_DSA file is already on your desktop. Then type the following into your terminal:

cp -frp id_dsa ~/.ssh

This will copy the key into the .ssh folder.

Next run the following command to add the identity to your computer.

ssh-add -K id_dsa

You will then need to type in the password you used to generate the key in cPanel.

You should see a confirmation that the identity has been added to your Mac. When this is complete, you will be able to use the SSH command to login to the server. The cPanel user name will need to be used along with the server name. The command will look like this:

ssh -p 2222 cpanelusername5@servername.inmotionhosting.com

Here’s an example: ssh -p 2222 user5@ecbiz188.inmotionhosting.com)

If this is the first time you have connected the server, you may see a message stating that it can’t identity the server. Just click on “YES” to proceed (just make you’re connecting to the right server). The password should automatically work and you should see the terminal connect.

This completes the tutorial for creating a new SSH key to connect your Mac terminal program to the InMotion Hosting shared server SSH. For best security practices, make sure to keep your key private and don’t share the password unless necessary.

Thoughts on “Connecting to a Shared Server SSH with a Mac”

I recommend double-checking to make sure the key generated is “authorized”. By default, it is not authorized after you initially create it. If it is authorized, try downloading the file again and moving it to the .ssh folder on your Mac.

If issues persist I recommend removing the key and trying to generate a new one. Be sure to keep a note of the password, to ensure you are entering it correctly. Also, be sure that you complete the authorization step.

These instructions are for shared hosting. With VPS, you should be able to use your default cPanel username and password. If that doesn’t work, I’d advise contacting Live Support so they can help check the SSH log.

Failed to add the host to the list of known hosts (/Users/clientuser/.ssh/known_hosts).

cpanelusername@serverip: Permission denied (publickey).

error.

I’m on mac version 10.13.3. I have a .ssh directory with the id_dsa file inside although I can’t physically see the .ssh folder anywhere and I chmod’d the privilege of id_dsa to 600 to add the identity and entered the correct cpanel credentials. I tried everything in the comments for this problem.

Yes, the cpanel username displaying a prompt indicates that you have successfully connected. I would check the permissions on that file and directory/location to ensure that the SSH Client you are using is allowed to read/write from/to that file to avoid the error in the future.

Sorry for the problem with running the command line that you are seeing. First, make sure that you are logged in as the Administrator with Root access. It might also be a part of the system integrity protection that is part of your operating system. A few people have run into this before and there is a fix for it discussed here. This issue may depend on the version of the OS that you are using. If you do a simple search for “operation not permitted Apple terminal”, you will see the different solutions that have been provided with the various conditions that can cause this.

I’m not aware of a method to accomplish assigning keys to a specific directory in SSH. The keys are implemented for login purposes only. Once a user is logged into SSH, the permissions to access and ownership of directories and files, apply as configured in the file system.

As per the article above you don’t need the public key to connect to SSH. The public and private key pair is generated on the server. The public key resides on the server and the private key is downloaded onto your Mac so that it can used in the client being used to connect to SSH. If you ever need to see all of the keys being used by your Mac, you can use the keychain app. I hope this helps to clarify the issue. If you have any further questions, please let us know.

I’ve tried everything in this feed and I still get operation timeout. Any ideas? I have generated the keys. They are authorized. Private key is in .ssh. I have chmod 600 and added to ssh. Trying to connect on shared server via -p2222. What am I missing?

An operation timeout generally means your SSH client go no response from where it was trying to connect to. The most common causes of this are an incorrect address or a firewall issue. I would recommend trying to SSH to the IP of your shared server instead of using the server name or your domain name. If that does not work I would check your firewall on your computer and local network to ensure they are not blocking your connection.

That means your permissions for your key file are set to 644, however, private keys should only be readable by your user for security purposes, you need to set the permissions to 400, 600 will work on most systems as well but 400 is what it should be. You can do this by running “chmod 400 path/to/your/private/key”

The error you’re seeing may depend on how you’re connecting (or what you’re using to connect) to SSH. Check out this forum post and see if matches the issue you’re having. If you are unable to resolve it then please contact our live technical support team (if you’re an InMotion Hosting customer), as they have the necessary access to review the issue directly and resolve it.

how to connect ssh -p2222 cpanelname@servername.com guide me on this what to typ correct credentials as im using godaddy. im at terminal everything added guide me this command according to my servername

Your instructions say “Leave the key type at DSA and key size at 1024” but it defaults to RSA/2048. I’m assuming the default is the option we should go with now; if so, you might want to update your docs to say the same thing.

For Linux, this is fairly more simple than on Mac (which is what the above article is about). You just need to generate a key in your local computer with ssh-keygen -t rsa and copy the public key into the “authorized_keys” file in .ssh folder on your server.

actually, I’m aware about that and i did follow to the letter your instructions with sensitvite K as I checked in man ssh that is the right command but I’m still getting the same error. Checking internet I could’nt find anything. What does it mean the error message? is it a bad file or wrong command option?

I’m in ssh folder and I’m running the following file:

ssh -add -K ~/.ssh/id_rsa.1475429822

after copying the id_rsa.1475429822 into the folder as it was described in your post.

If the command posted here is the command being used then it appears there is still a space after ssh. I suggest trying to copy and paste the command from the article above to see if that gets the desired result.

Hi, Thanks for the tutorial. I have setup the ssh like this tutorial. But when I am going to connect it’s showing this message “ssh: connect to host [myServerIp Here] port 2222: Connection refused”. Any idea?

Sorry for the problems with getting into SSH. I know that you’ve posted your question in the SSH instructions for Mac, but what version of OSX are you using? Did you go through the steps listed above? Can you please provide account information so that we can check it? We would need more information in order to troubleshoot the issue. Please give us a little more info and we would be happy to help.

InMotion Hosting is a leading web hosting company serving customers around the world. We provide reliable, high-performance hosting environments that are affordable and easy to use, but the hallmark of InMotion is excellence in customer service. Our aim is to delight every customer with friendly service that is readily available, expert and effective.
InMotion is a trusted partner for businesses both large and small, with over 10 years in the hosting business and over 100,000 satisfied customers hosting their websites on our servers. We care about our community and the environment, with green data centers and ongoing sustainability programs.

LIMITED TIME ONLY! Get all the amazing speed and performance of our WordPress Hosting Platform, including free SSL and much more. That means you get 2 websites, 80GB of storage, unlimited email accounts and a FREE JetPack Personal License, all for $6.99! https://zcu.io/eCNw