ssh - EC2 - ROOT & SUDO not working

08
2014-07
  • Black0CodeR

    I've setup an EC2 instance(PHP, MySQL, phpMyAdmin).

    Last night I accidentally execute some command that messed up the permissions.

    I was able to login as root before (to ssh using puTTy) but now when I try to login using root I get error which says login as ec2-user instead of root.

    Now, If I log in using ec2-user and do sudo. I get error sudo: effective uid is not 0, is sudo installed setuid root?. When I try to login using su or su root. I get Password: and I didn't set any password and default NO PASSWORD is not working, too.

    Now, I can't give permissions to sudo for root because sudo is broken and I can't login as root to change permissions because it's asking for password.

    How can I overcome this problem?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    osx - Mounting an Amazon EC2 instance on Mac OS X
  • user26767

    I've got public key authentication working between my Mac OS X and an Amazon EC2 instance so that from the command-line I can just type the following and it works:

    ssh root@[IPAddressOfEC2Instance]
    

    The strange thing is that I can't seem to mount the instance using "Connect to Server" in the Finder.

    I've tried typing the following server addresses into the "Connect to Server" dialog:

    ftps://[IPAddressOfEC2Instance]
    ftps://root@[IPAddressOfEC2Instance]
    

    But all I get is

    You entered an invalid username or password. Please try again.

    The root user on the EC2 instance has a blank password and I'm wondering if it has to do with that. However, I can't change the password for the root user.

    I can use an SFTP client to connect to the machine, I just can't mount it with "Connect to server". It asks for a username and password (for a registered user) and it's root/[blank] which it doesn't accept. The other option is "Guest" which brings up an empty folder in the Finder.


  • Related Answers
  • Eric Boehs

    SFTP is not the same as FTPS. FTPS is FTP using SSL. SFTP is secure file transfer protocol (over SSH). (Mac OS X's FTP/FTPS support in Finder is pretty pathetic anyways.)

    Mac OS X can not natively mount SFTP shares. There is a way to do it using MacFUSE. It's rather difficult to set up and there's not a reliable non-commercial GUI application to manage it. There are a couple packages you have to install and a lot of command line hackery to get shares to mount (don't get me started on auto mounting them). It's really not worth the effort. I have done it a couple times before, but it was hell; I have found a much better solution: ExpanDrive.

    It's a commercial program but it's worth every penny. It uses MacFUSE and allows you to mount SFTP, FTP/FTPS, and Amazon S3 "drives". You can download a free trial which works for 30 days. (Also, it won't expire unless you close it. :))

    In order to get it to work using public key pairs you'll need to add your SSH private key to your Mac OS X keychain:

    ssh-add -K
    

    Then when you create a new drive in ExpanDrive leave the password field blank, but check the "Save" box.

    You should be good to go. The great thing about ExpanDrive is it will auto reconnect the drives if the connection gets dropped (wifi drops, you sleep/wake your mac, you reboot).

  • Josh K

    You may need to enter the username and / or password in the "Connect to Server" box in finder.

    ftps://root@[IPAddressOfEC2Instance]
    

    You can alternatively use a standalone FTP application like FileZilla or Transmit.