Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@shahzzzam

This comment has been minimized.

Copy link

commented Sep 28, 2015

My hostgator server has something called jailshell which I guess does not allow access to the sudo command:

screen shot 2015-09-28 at 3 05 23 am

Plus, I don't know why this happens? Is it not linux?

screen shot 2015-09-28 at 3 06 42 am

And most importantly, can you please elaborate why would we need an extra user called deploy? Is there some reason behind it?

Thanks Will. You have amazing tutorials.

@jselesan

This comment has been minimized.

Copy link

commented Oct 5, 2015

Mi server uses a port different of 22 for SSH, but I do not realize how to specify the port on the command

scp /.ssh/id_rsa.pub deploy@url.com:/.ssh/authorized_keys

Could you tell me how to specify the ssh port?
Thanks

@jselesan

This comment has been minimized.

@jsdevtom

This comment has been minimized.

Copy link

commented Feb 15, 2016

@samarthmshah I have pretty much exactly the same questions as you. Have you found the answers yet? I found the answers to one of your questions in te comments section of the video:
Jordan Adams: "The reason to opt for a secondary deploy user is purely security. Normally you'd go ahead and root (limit) this user to the app's location on the server. That way if the deploy account is compromised by for example a disgruntled developer, the rest of the server is safe.

The reason for setting up passwordless auth for this deploy user is so that you don't have to enter a password for each deployment. Instead you're authenticating by a private key on your machine."

@hintonbradley

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jan 27, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.