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)

2

2 Answers 2

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.

2
  • Nice one! This is a secure way to use WinSCP. Nov 3, 2011 at 10:55
  • Perfect! Old and still works!
    – tmarois
    Sep 21, 2017 at 14:30
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.

2
  • 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? Jul 28, 2011 at 6:32
  • chmod 777 /drop and use WinSCP normally to drop your files into that folder.
    – bobobobo
    Apr 23, 2013 at 2:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .