7

0 down vote favorite

1) How can I login amazon ec2 with root directly in putty??

each time i need to su - root first and change to root...is there any other ways??

2) How can I login amazon ec2 with root directly in winscp or filezilla??

since i want to "push" the file to some directly from my computer, but i cannot do this (e.g.create dir when login with ec2-user)

red23jordan
  • 221
  • 1
  • 3
  • 4
  • Allowing direct root logins from the internet is contrary to [industry-standard security practices.](http://www.tectia.com/Manuals/server-zos-admin/62/Securing-sysamin.html) – Skyhawk Jul 28 '11 at 06:04
  • The industry standard security practices are antiquated in this regard. – anastrophe Jul 28 '11 at 06:41

2 Answers2

9

WinSCP supports SSH keys.

In /etc/ssh/sshd_config set

PasswordAuthentication No
PermitRootLogin without-password

Copy your public key to /root/.ssh/authorized_keys (there will be a similar file inside of ec2-user's home directory). If you want to just copy that type

sudo mkdir -p /root/.ssh
sudo cp /home/ec2-user/.ssh/authorized_keys /root/.ssh/

This way you can login as root but only with ssh keys. If you have already assigned a password to root, you can disable the password on the account by typing:

sudo passwd -l root

You will also need to reload ssh:

sudo service sshd reload

Assuming you have already converted the amazon public key file to putty format, point WinSCP to that private key file and you should be able to login without a password. If you have not converted the key file you can use puttygen to do so.

Jared Bartimus
  • 341
  • 1
  • 2
3

Edit /etc/ssh/sshd_config, change these lines

PermitRootLogin forced-commands-only
PasswordAuthentication no

To:

PermitRootLogin yes
PasswordAuthentication yes

Set a password for root and restart sshd.

passwd
service sshd reload

Disclaimer: I don't recommend this at all, but since you asked I'll give you the gun - you decide what to do with it.

h0tw1r3
  • 2,746
  • 18
  • 17
  • the main reason i want to do this is I need to transfer file from my local PC to server...the way i usual use is through winscp..however, i can just transfer file from server to local, but from local to server fail...i know it is very dangerous to let root access directly..but do you have any way to transfer file? – red23jordan Jul 28 '11 at 06:32
  • `chmod 777 /drop` and use WinSCP normally to drop your files into that folder. – bobobobo Apr 23 '13 at 02:23