Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been experimenting with a patching process for deploying files to a webserver.

At the moment I'm using scp to get the zipped directory structure onto the webserver and then cp -rf --backup=t patch* www/

e.g.

user$ scp patch.zip server:~
user$ ssh server
// some welcome message, I have mail!, etc...
user@server:~$ unzip patch.zip
user@server:~$ tree
.
├── www
│   ├── 1
│   ├── 1.~1~
│   ├── 2
│   ├── 3
│   ├── 4
│   └── numbers
│       └── one
└── patch
    ├── 1
    ├── 5
    └── numbers
        ├── one
        └── two
user@server:~$ cp -rf --backup=t patch/* www/
user@server:~$ tree
.
├── www
│   ├── 1
│   ├── 1.~1~
│   ├── 1.~2~
│   ├── 2
│   ├── 3
│   ├── 4
│   ├── 5
│   └── numbers
│       ├── one
│       ├── one.~1~
│       └── two
└── patch
    ├── 1
    ├── 5
    └── numbers
        ├── one
        └── two

I'm not sure where I should be going to make this a deployment script, e.g. can a locally executed script run commands on the remote server? if so how?

share|improve this question
up vote 0 down vote accepted

it certainly can.

scp patch.zip server:~
ssh server "unzip patch.zip"
ssh server "cp .... "

The question is: is it sane. You can easily achieve this with passwordless ssh authentication (key-based). But there's a good lot of risk to it.

An alternative would be to use methods like salt, ansible, puppet, chef, ...

share|improve this answer
    
I'm not sure how there's any more risk in automating this and reducing the chance of human error (forgetting the --backup flag for example) than in the current workflow. Or is it the current work flow you consider risky? – Luke Jan 30 '14 at 23:26
    
@Luke - I consider the use of ssh-keys in a scripted environment problematic. If the machine the script resides on gets compromised with a password-/passphrase-less login the data on the target machine becomes instantaneously available, too. You could consider using a forced command on the far end to mitigate the problem to a large extent. – tink Jan 30 '14 at 23:40
    
I see. Thanks for clearing that up fortunately the script will prompt you for the SSH password so the problems mitigated somewhat. I can see why using an SSH key to avoid this wouldn't be a wise idea. – Luke Jan 31 '14 at 3:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .