Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinSCP connect to Amazon AMI EC2 Instance changing user after login to "root"

I followed instructions here carefully however I haven't get this working right. Here is what I did:

  1. Run WinSCP enter Hostname (Elastic IP of my Instance)
  2. enter username "ec2-user"
  3. enter public key file
  4. chose SCP for the protocol
  5. Under SCP/Shell settings I chose "sudo su -"
  6. Hit Login
  7. WinSCP asks me for passphrase key, Hit OK
  8. Shows up this error

Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended).

NOTE: This works on Putty

like image 223
Aivan Monceller Avatar asked Jun 20 '11 16:06

Aivan Monceller


1 Answers

With credit to this post and this AWS forum thread, it seems the trick is to comment out Defaults requiretty in sudoers. My procedure now:

  1. Log in to your EC2 instance using Putty.
  2. Run sudo visudo, a special command to edit /etc/sudoers.
  3. Press the Insert key to start Insert mode.
  4. Find the line Defaults requiretty. Insert a hash symbol (#) before that line to comment it out:
    #Defaults requiretty
  5. Press the Esc key to exit Insert mode.
  6. Type :wq to write the file and quit visudo.

In WinSCP:

  1. Under Advanced > Environment > SCP/Shell, change the Shell to sudo su -.
  2. Under SSH > Authentication, choose your Private key file (.ppk file).
like image 178
Mark Berry Avatar answered Nov 03 '22 08:11

Mark Berry