SSH key setup
Setting up local SSH keys
If you don't already have a private SSH key, typically located at ~/.ssh/id_rsa
, you will need to create one. Fortunately, this is an easy task.
Optionally, you can create a SSH key specifically for use with the swarm, next to your other SSH key(s).
Edit your local SSH config file
Assuming you've already added your SSH public key to /root/.ssh/authorized_keys
on your server, consider adding a host entry to your local ~/.ssh/config
file to make things easier:
Host alias
Now ssh root@123.23.12.123
becomes ssh swarm
This alias makes it easy to connect or reference your server in projects.
Adding a git remote
In order to push and deploy apps to the swarm, we need to add a git remote to our project repository.
Swarmlet creates a user named 'git' on the server, this user handles incoming changes.
If a project doesn't exist already, a new repo will be created on the swarm named <project-name>
.
Remote user
When specifying a remote, the remote user must be 'git'. And because we've updated our ~/.ssh/config
file, we can specify the host by it's name, 'swarm' in this example.
Adding a git remote in a project that points to your server is as easy as running:
Now you can deploy an app simply by running git push swarm master
Pretty easy to remember!