thisbythem / stag

The Statamic CLI
36 stars 4 forks source link

Deployment Issues #2

Closed jhough10 closed 9 years ago

jhough10 commented 9 years ago

Using the command-line for deploying and clearing cache is great. However, the one issue that I am having is that no matter what command I run it will always ask for my password. For example, I setup a sample deployment to sites staging environment and ran into some issues because it will request that I type my password for each step in the process which is upwards of 10+ times for each deployment I have tried to run.

I figured it might be my configuration file (structure is below), but no matter how many times I have tried to mess with the configuration file it will continually request my password to be typed at each and every step. The deployment works flawlessly when I check the files after it is complete, but having to type my password that many times seems to defeat the purpose of using the command-line.

Any ideas on what it happening? I am currently on Dreamhost now, but I haven't had issues before using rsync over ssh before.

servers: 
  staging:
    host: example.com
    webroot: /var/www/example.com
    user: ******
    password: ******
    port: 22
    forward_agent: false
    strategy: rsync

    deploy:
      pull_content_before: true
      clear_cache_after: true
      set_permissions_after: true
      ignore_files:
        - .git
        - _cache
        - _logs

    pull_content:
      content_directories:
       - _content
       - assets
nobodyiscertain commented 9 years ago

It sounds like you don't have passwordless login for SSH. Are you able to SSH into your server without entering in your password?

If not, you'll need to generate some keys on your dev machine, and copy the generate public key to the authorized_keys file on your server. How to do that will vary depending on your computer, but Dreamhost has a guide here that should help: http://wiki.dreamhost.com/SSH (scroll down to passwordless login)

Let me know if that helps.

jhough10 commented 9 years ago

@nobodyiscertain that does make sense, but if Stag is running rsync via passwordless SSH, then what is the point of setting the password. Is that only used for FTP?

nobodyiscertain commented 9 years ago

@jhough10 Great point. It is currently only used for FTP, but there isn't really any reason that it can't be used with SSH too. I'll get something hacked together tonight or tomorrow for ya.

jhough10 commented 9 years ago

Awesome! Thanks, @nobodyiscertain. I don't mind being a guinea pig since this has been something that will really help all the clients that I build Statamic for.

nobodyiscertain commented 9 years ago

So turns out I'm gonna have to require some dependencies or use a different library for the SSH connections in order to make this happen. I'm fine with doing so, but would rather not have dependencies in order for users to use an ssh password.

Are you able to rsync without it asking for your password? If so, can you copy in that command? (with your user/pass starred out) All stag is doing is constructing the commands to run as your user, so if you are able to rsync without entering your password, I should be able to replicate. Might take a little more refactoring than I thought to make this happen...

jhough10 commented 9 years ago

@nobodyiscertain I was able to set up the password-less process just fine. I used that method to do automatic GIT deploys between servers so I am comfortable setting that up locally.

I would agree with you about the dependency issue so I wouldn't worry about adding that kind of complexity.

nobodyiscertain commented 9 years ago

Ok great. I believe it's more secure that way too instead of sending your password over the wire.

I'll update the README & config to reflect that passwordless SSH is required.

nobodyiscertain commented 9 years ago

I updated the README to say passwordless ssh access is required. I also updated the password setting in the config to be ftp_password so it's a little more explicit in it's purpose.