SSH Keys with 1and1 Hosting


I recently upgraded my hosting package with 1and1 and now able to use SSH to connect to my webserver! There were a few different places out there that I had to piece together in order to setup my SSH keys with the 1and1 server so I decided I would consolidate my findings here.

Generating Your Key Pair to Use with 1and1

user@machine:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa): /home/user/.ssh/1and1_hosting
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/gbrands/.ssh/1and1_hosting.
Your public key has been saved in /home/gbrands/.ssh/
The key fingerprint is:

I use a lot of SSH connections in my line of work and I try to keep them as separate as possible by generating a unique SSH key pair for each of the servers I connect to. By specifying the file in which to save the key, you are able to have a unique pair for each of the hosts.

I also like to specify a passphrase for the key just to be on the safe side. A family member could possibly use my computer and accidentally execute one of the commands I issued last and connect to the remote server and specifying a simple passphrase prevents this from occurring.

However, you could just use the default and hit enter for each of the prompts.

Adding Your 1and1 User Name to the Config File

Chances are your 1and1 user name used to connect via SSH (the same as the main FTP user) is different than that of your local user account on your machine. In order to circumvent having to use the 'l' flag everytime with SSH, I found it much easier to provide a config file with this information. You would save this locally in your ~/.ssh directory

~/.ssh/config (if this file doesn't exist, just create one)

Now you will be able to just type in ssh

Adding Your Public Key to 1and1

Once you have generated your key pair, the next step is to add it to your 1and1 web server. By default, you don't have an .ssh directory in your home directory (at least I didn't). So you'll have to make one and add your public key to an authorized keys file.

(uiserver):1and1user:~ > mkdir .ssh
(uiserver):1and1user:~ > cd .ssh/
(uiserver):1and1user:~/.ssh > vi authorized_keys2
(uiserver):1and1user:~/.ssh > exit

Connecting to your 1and1 Web Server

Now that you have your SSH key pair added to the 1and1 server, you should now be able to connect by simply typing in the command ssh!

1 comment

by Anonymous (not verified) on Mon, 03/28/2016 - 19:56

Thank you! Adding the key will save me a lot of headache in the future.

SSH Keys with 1and1 Hosting | Gerrit Brands

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /homepages/29/d196880538/htdocs/drupal7/includes/ in drupal_send_headers() (line 1212 of /homepages/29/d196880538/htdocs/drupal7/includes/
  • PDOException: SQLSTATE[42000]: Syntax error or access violation: 1142 INSERT command denied to user 'dbo354826752'@'' for table 'watchdog': INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => cron [:db_insert_placeholder_2] => Attempting to re-run cron while it is already running. [:db_insert_placeholder_3] => a:0:{} [:db_insert_placeholder_4] => 4 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => 1521872910 ) in dblog_watchdog() (line 154 of /homepages/29/d196880538/htdocs/drupal7/modules/dblog/dblog.module).


The website encountered an unexpected error. Please try again later.