How to login amazon ec2 with root directly in putty or winscp

amazon ec2puttywinscp

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)

Best Answer

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.