How do I connect with SSH to directadmin?
Back to scripts and softwareSSH stands for Secure SHell. Usually you don't need this when you are setting up a simple site, because most of the functionalities of SSH can be solved through other means such as FTP.
What is SSH?
SSH is a protocol that allows you to connect to the server. You can easily enter commands and have them executed by the server.
What can I do with SSH?
With SSH you can easily change the owner of folders and permissions, for example. There is one main account that can manage everything, with an unmanaged server you have access to this main account. Of course, we use this account ourselves on our shared servers when necessary. The main account can of course do much more, for example install programs, modify configuration files, etc.
What rights do I have with SSH?
On our shared servers, customers can access SSH.
The SSH is based on user level rights.
This makes it possible, for example, to manage your own files and modify things within your own folder. Of course, you cannot install programs or modify configuration files yourself, because this is outside your own directory.
What do I need for SSH?
Many of our servers are secured with key authentication, which means that you need a key (in the form of a file) to access SSH.
You need 2 keys for this, a public key and a private key.
The public key is added to the server, the private key is for yourself and you give it to the SSH connection to authenticate yourself.
Once a connection is made without a key, the server will return an error message, as shown below.
How do I get a private key and/or a public key?
If you are using Windows, you can use the program Puttygen to create a private and a public key.
Once you have downloaded Puttygen, click on the generate button as shown below:
Move your mouse a few circles over the gray area so that the key is generated.
There is now a public key visible on the screen, this key is important, save it somewhere by selecting it with your mouse, right click on Copy. We will add this key to the server.
After a public key is created, you may also have the option to add a password to this key, so that if your colleague for example has the key he/she still can't get in because a password is required. It is recommended that you do fill this in.
Since we have already saved the public key now click Save private key and save it somewhere where you can easily find it again. .
With OSX you can do this through the terminal app found in the utilities folder... Once you have the terminal open you can issue the following command: ssh-keygen -t rsa
Add public key in DirectAdmin
Login to the control panel of DirectAdmin
Go to Advanced Features and click on SSH keys as shown in the image below:
Click on the button: PASTE KEY to add the previously copied public key to the server.
If it is successfully added you will get the message: SSH key authorized as shown below:
I added the key, how can I connect now?
To connect to SSH you need a program. You can find many programs on the internet, a well known program is Putty for example, but in OSX there is also a program called Terminal in Utilities that can also connect to SSH.
How to pass the private key to SSH:
To connect, you must provide the key with the SSH connection.
This can be done in 2 ways.
- You can use the putty agent (paegent) which you can download from the same website where you downloaded puttygen.
- You can specify the SSH key in putty itself.
Using keys with Putty Agent
Personally I find putty agent the easiest, this is a little program that appears in the lower right corner of your active windows applications.
The icon looks like this
Double click on the icon, and click on the button: Add key.
Select the private key.
Now open Putty itself and you should now be able to successfully establish an SSH connection.
Note that upon rebooting your computer, the putty agent stops and you need to add the key again.
Using the key with Putty itself
Open Putty
In the left menu, click on SSH and then Auth as shown in the picture below:
Next, select your private key.
Then click Session in the left menu and enter the server information as shown in the picture below:
Give the session a name and click Save so you can easily connect it in the future with just one click of a button.
If you do not do this, you will have to provide the private key each time.
Once you start connecting you will get the following message:
Click Yes to add the key to your computer so it will not indicate this in the future.
When prompted for a username, enter the DirectAdmin username.
Back to scripts and software