In this article, I’ll walk you through how to easily and automatically deploy code from your Git repository to your SSH server with zero downtime.
There are several ways of uploading code to your SSH server. You could, for instance, use an SFTP client, or install git onto your server and run a git command such as
fetch to update sources in your repository.
Both methods are relatively quick and simple, but they’re still manual processes requiring you to log into your server. On top of that, these methods don’t allow for “zero-downtime deployments”, or for easily and automatically running build steps such as installing dependencies.
A major advantage of SSH is that it allows for commands to be executed on your server, including the creation of symlinks. This enabled Launchdeck to publish new versions of your project without any downtime at all. The way this works is by adding an entirely new directory for each new version, to which a symlink from your server’s webroot will be created or updated once you wish to publish this new version.
An additional advantage of this is that it allows you to instantly roll back to a previous version - with no more than the push of a button - when the new version doesn’t appear to work entirely right.
Before we get started
When you first start using Launchdeck to improve your deployment process and development workflow, it’s important that you’re already using Git, and have access to an SSH server that you wish to deploy code to. If you’re not already using Git, do yourself a favor and look into it! Git’s main website has some great resources to get you started.
We offer a free full-featured plan that allows you to deploy one project as often as you’d like!
Create a project
Once you've signed up for a new Launchdeck account, you can create your first project and link it to your Git account. All repositories within your account will be retrieved and shown as a list, from which you can now select the one you’d like to use.
Setup your build
The next step allows us to define commands which will be executed in an isolated docker container - this is the build step. You can use this step to, for example, compile assets, install dependencies, run tests, and everything in between.
All files generated using these build commands will be uploaded to your server. You’ll find more information on how to set up and use build commands in our build commands docs.
Configure an SSH server
Now let’s tell Launchdeck where to upload the files.
Pick ‘SSH’ as the server type and give it an easily recognizable name.
Enter your server’s hostname, and optionally the SSH port if you wish to use a different port (the default ‘22’ is standard for the SSH protocol).
Enter your username, and you’ll then be presented with two choices in terms of authentication: an SSH key or a simple password.
If you opt for the former option, we’ll generate a public key for you as well as a one-liner that you may run on your server to add this key to the “authorized_keys” file.
It’s not uncommon for a shared hosting provider to offer semi-restricted SSH access, for which you’ll need to add the SSH key through the web interface offered by your hosting provider. In this case, copy the public key using the “copy the public key” link and add it through said web interface. Often, you’ll also have to whitelist our IP address or explicitly link it to the key address you’re adding. You’ll find the appropriate IP address in the “Server configuration” modal (note that this IP address might be different across projects or users).
The installation path is where your project will be stored on your remote server, all releases will be stored in
<Installation path>/releases, the current release will be available at the symlink
<Installation path>/current, and the shared files will be stored in
<Installation path>/shared. More information about how to use
shared files you’ll find in our build automation docs under the section ‘Shared’.
If you want to automatically link the webroot on your server to the latest release, fill the ‘webroot path on server’ in as well. On DirectAdmin-based systems, for example, this path will look something like
/home/<username>/domains/<domain>/public_html. Or if you created a separate user with only access to the domain you are deploying to, you should then set your webroot to
To figure out whether the server connection data is correct, run the server connection test and we’ll try to connect to your server and check the provided path(s).
Deploy for the first time
We’re now ready to start our first deployment. Click ‘create new project’ to confirm the settings and add the project. In the project overview, you can now start the build. The code will be cloned from your repository and prepared for you to publish it. Hit ‘Publish’ and your code is live!
If we then commit changes to our repository, the commit will automatically appear in your project overview where you’ll be able to upload and publish your new version with the push of a button. If anything goes wrong, you can simply roll back to the latest working version.
That’s all! By using Launchdeck to deploy to your SSH server, you’ll never have to upload a new version or run commands manually. Just hit “publish”, and Launchdeck will deploy your site or app with zero downtime.