Skip to content

Instantly share code, notes, and snippets.

@learncodeacademy
Last active October 8, 2022 18:56
Show Gist options
  • Save learncodeacademy/3cdb928c9314f98404d0 to your computer and use it in GitHub Desktop.
Save learncodeacademy/3cdb928c9314f98404d0 to your computer and use it in GitHub Desktop.
Adding a deploy user in Linux

(wherever it says url.com, use your server's domain or IP)

Login to new server as root, then add a deploy user

sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy

And Update the new password

Now login as that user

ssh deploy@url.com

Make directory .ssh on the remote server and log out

mkdir .ssh
exit

Push your ssh key to the authorized_keys file on the remote server

scp ~/.ssh/id_rsa.pub deploy@url.com:~/.ssh/authorized_keys
@hintonbradley
Copy link

hintonbradley commented Jan 27, 2019

Hey all.
I'm running a node app but using a server.js file in the root directory. I've gotten to the point where I want to deploy my app, but whenever i run 'fly production' I get the following error:
> error: Forever cannot find process with id: /home/deploy/moshHamedaniNode/server.js

My flightplan.js file starts out like so:

var plan = require('flightplan');
var appName = 'moshHamedaniNode';
var username = 'deploy';
var startFile = 'server.js';
var tmpDir = appName+'-' + new Date().getTime();
...

Finally, the following files are all located in the root directory:
flightplan.js
package.json
server.js

As far as I can tell the appName, username and startFile variables are all named correctly in the flightplan.js file. Can anyone give me some feedback as to why I'm getting this error?

@hintonbradley
Copy link

As far as I can tell the appName, username and startFile variables are all named correctly in the flightplan.js file. Can anyone give me some feedback as to why I'm getting this error?

Looks like I was able to fix the issue by changing my flightplan.js file to this:
var appName = 'node-app';
var username = 'deploy';
var startFile = 'server.js';

However, now when I go to my IP address I get the error: This site can’t be reached - refused to connect. Do I still have something wrong in my flightplan.js to keep it from deploying my code to my droplet?

@rempargo
Copy link

I guess, the advantage of one single deploy user, when you have more than one developer, is that when one developer do a git pull and another developer too, some files might get different ownership settings and we have to fix it with chown. I think our problem can also be fixed with proper group rights. Like to hear comments about this. "Proper group rights VS additional deploy user:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment