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

Aivan Monceller picture Aivan Monceller · Jun 20, 2011 · Viewed 9.6k times · Source

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

Answer

Mark Berry picture Mark Berry · Aug 5, 2014

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).