How can I login to Amazon EC2 with
Each time I need toroot
directly in PuTTY??su - root
first and change toroot
... Is there any other ways??How can I login to Amazon EC2 with
root
directly in Win开发者_如何学PythonSCP 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
)
Change the PermitRootLogin
setting from no
to yes
in your sshd_config
file, then restart your SSH server.
When setting up a server, the simplest solution, really, is to just upload the file as root – probably not the best idea from a security perspective, but it really does save a lot of effort when you are copying configuration files back and forth between machines.
On the EC2 instance run:
# visudo (or edit /etc/sudoers)
Comment out Defaults requiretty (line 55)
(or change to Defaults !requiretty)
In WinSCP:
Under Session:
Set the username to same username you login with (the default is ec2-user)
Change the File protocol to ‘SCP’
Under Environment > SCP/Shell:
Change the shell to 'sudo su -' (available in the dropdown)
Login and you should find yourself in /root. Once you no long need to use SCP as root, it is advisable to re-enable requiretty.
Source: http://www.thatsgeeky.com/2011/10/connect-to-amazons-linux-via-winscp-as-root/
- With WinSCP you should first identify the location of the sftp-server
You can run the following command:
find / -name sftp-server
In my case, the location was: /usr/libexec/openssh/sftp-server
The previous location should be configured in WinSCP in your session: Advanced Site Setting > SFTP > SFTP Server
sudo /usr/libexec/openssh/sftp-server
I use Filezilla to login, and follow the steps below.
To connect to a running Amazon EC2 instance with Filezilla:
Edit -> Settings -> Connection -> SFTP Click "Add keyfile"
Browse to the location of your .pem file and select it.
A message box will appear asking your permission to convert the file into ppk format. Click Yes, then give the file a name and store it somewhere.
If the new file is shown in the list of Keyfiles, then continue to the next step. If not, then click "Add keyfile..." and select the converted file.
File -> Site Manager
Add a new site wih the following paramerters:
Host: Your public dns name of ec2 instance
Protocol: SFTP
Logon Type: Normal
User: ec2-user
Press Connect Button
Video Tutorial: Click Here
精彩评论