User Tools

Site Tools


editing_files

Getting Started Part 4: Editing Files

How to edit files on a remote server (i.e. on your Amazon EC2 instance):

Windows

Download Notepad++ from https://notepad-plus-plus.org/download/ (alternative download link)

Once installed, click PluginsPlugins Admin and search for NppFTP, tick the checkbox then click Install.

After Notepad++ restarts, click PluginsShow NppFTP Window

Then, in the top right window that has now appeared docked in your Notepadd++ window, click the Settings icon (the gear), then Profile settings

Click Add new and give it a name.

Enter your details for your Amazon EC2 server:

HostnameYour EC2 IP address (or hostname)
Connection typeSFTP
Usernameubuntu
Initial remote directory/var/www/html/

Click on the Authentication tab, untick Try password authentication and tick Try private key authentication, then click on the browse button next to the Private key file box, find your original PEM file (not the converted PPK file).

Once that key has been selected hit Close.

You can now connect to your server by using the top left Connect icon in the NppFTP window (top right section of Notepad++) and choosing the server you named above.

You should now be able to see/edit the test.php file you created earlier.

Linux

You are able to mount your remote server directly using sshfs:

sshfs -i identityfile.pem ubuntu@your_ec2_ip:/var/www/html/ my_ec2_server/

You can then use any editor and access the server files directly from the my_ec2_server directory.

MacOS

To transfer a file to the server with minimal fuss then use the built in Secure Copy command:

scp file.php ubuntu@your_aws_ip:/var/www/html

However, for transferring many files you may want to mount the remote directory with sshfs

Install the package manager HomeBrew if you don't have it already: https://brew.sh/

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Now use HomeBrew to install sshfs

brew cask install sshfs

Create a shortcut for your server by using this template and saving it to .ssh/config in your home directory (/Users/yourusername)

Host server_name
    User    ubuntu
    Port    22
    HostName    IPADDRESS
    IdentitiesOnly  yes
    IdentityFile    file_location

For example:

Host my_amazon_server
    User    ubuntu
    Port    22
    HostName    10.45.23.1
    IdentitiesOnly  yes
    IdentityFile    /Users/neil/myamazonkey.pem

Make sure you can ssh into your amazon server using the server_name, e.g:

ssh my_amazon_server

If that works, you can use a similar sshfs command as above:

sshfs my_amazon_server:/var/www/html/ my_ec2_server/

More discussion can be found on the group forums

editing_files.txt · Last modified: 2019/09/11 00:21 by ed