4

I try to login using the ec2-user but for some reason the login fails:

Using the username: ubuntu I am able to login just fine, however, I don't have any privileges and I can't sudo su for the privileges to write to my files. I tried using the cyberduck terminal and send command options but sudo su doesn't work with them. Cyberduck just spins.

j will
  • 3,747
  • 11
  • 41
  • 64

1 Answers1

0

I don't think the ec2-user account works on recent Ubuntu AMIs, which may explain the failed login.

You can approach this in a few ways. The first is to create a new user account specifically for FTP and give it permissions only to the necessary folders. First create the user, then create a public/private key pair for non-interactive login. This will allow you to operate your FTP client like normal.

My preferred solution is to upload the files to the ubuntu home directory and then run a script as root that moves the files to the correct location. You won't have to modify the system configuration this way, but you will have to do the file transfer in two steps.

Create a staging folder in /home/ubuntu and copy the files there. Create a /home/ubuntu/copy.sh script on the server like this:

#!/bin/bash
sudo su     #this will only work if sudo doesn't prompt for a password
cp -r /home/ubuntu/stage/* /var/www/html/

Then from your dev machine, call the script:

$ ssh -i ~/path/to/key.pem ubuntu@ec2.hostname.com /home/ubuntu/copy.sh

If you want to get really fancy, you could set up a git repository and use a post-receive hook to handle this all for you when you push. No need for an FTP client at all.

Community
  • 1
  • 1
Steve Nay
  • 2,819
  • 1
  • 30
  • 41
  • So I don't think the first option worked. All i am getting is a Permission denied (public key). I wonder if this is because I am working with an ec2 amazon instance where key pairs may be required. I don't plan on using the either two options. – j will Feb 22 '13 at 01:13