Is it possible to work with an editor remotly? - ssh

I want to edit files on my server, but don't want to always upload the files, is there a way on to edit the files remotly?
I tryed to make an bash script which should upload the files, but its not realy good :/ and sometimes didn't worked

You can use Atom with the
Retome FTP edit
Package

If you have got an SSH (SFTP enabled) access to your server, an option would be use use SSHFS to mount a remote directory on your local working path.
In this way you can use any editor (or even something else) to change your files and they will always be synchronised.
Just keep in mind that, in this way, files are actually located on your server, you won't have a real copy on your local machine.

Related

How to rewrite all same files to sites in root via SSH?

I have a hundred same sites in my root directory i want to modify one page and i must rewrite all sites , is there any easy way to modify them.
You can think as this, you have VPS root server and you set up 100 joomla in your server. They have different databases but all of them are same files.
And you must change footer.php file so what will you do?
You must open root and replace the footer file to all sites one by one.
And so it is a hard way. There must be easy way via SSH or Php codes, etc..
Thanks alot.
Use the editor of your choice and batch process all the files.
e.g. on Windows, mount the folder as a network drive, open all footer.php files in Notepad++ and do a search and replace on all open files.
e.g. on the Unix command line, use find (maybe xargs) and sed or vim -c. alternatively to something like the Windows approach with e.g. Sublime text or any other editor.

SSH Remote access in Aptana

I have since connected to my SSH site using Putty and Filezilla. Putty and Filezilla give me direct access to the appropriate directories and Filezilla gives me a full path from the top level directory. I have then tried the same path from the starting point in Aptana, but get blocked one level above my target directory. If I collapse all the directories in Putty and Filezilla and try to expand again, Putty works fine, but Filezilla then blocs at the same point as Aptana. So there is some subtle difference in approach between Filezilla and Aptana and Putty.
I was looking for a way to get an encryted link when editing files on my hosted webserver when using Aptana Studio. I can get an ordinary Remote FTP link set up and use that to edit files. The SSH facility looked as though it could do a secure link, so got the SSH details off my ISP and set up in Studio. In the setup I was asked to select a directory, but the ones available were all system directories rather than my htdocs tree. However by leaving out the default provided /, I could get to the htdocs tree and see all my files under remote. However when I try to load a file to Studio, I get a file does not exist message.
I'm new to SSH (and Studio) and don't know whether what I am trying to do is not possible or there is something else I need to set up. So far I have just been using Studio as a remote editor for PHP and HTML. I suspect there is a much better and professional way to set up what I am doing under Studio (even ignoring the secure transfer) as I am currently doing separate backup of the files in Filezilla, but just haven't figured out the way to set everything up yet.
Many thanks for any help.
Actually I'd like to post this as a comment to your question, but I'm pretty new here, so the system doesn't allow me to.
Anyway. You can add connections to remote servers over ssh like this:
If you don't have the remote tab go to Window -> Show View -> Remote
Rightclick in the remote tab and click "Add New FTP Site..."
Change the Protocol to SFTP and put in your credentials (you can use Username/Password or Username/Private Key authentification)
When you close Aptana with files still opened, it usually show you those files when you reopen Aptana later. It seams not to do this when you work with files of a SFTP remote host and shows you an error instead. I guess this is because it tries to validate those files (if they still exists) but doesn't authenticate with the remote host first. So nothing to worry there.
Hope this helps.

Text editor that can edit using sudo over ssh?

I'm trying to edit files on a remote Amazon EC2 Linux instance. I'm currently just sshing in and using nano, but would really like a graphical text editor. I have two problems:
I have to use sudo to edit these server files when I ssh in.
I can only login with the key Amazon gave me. Ex: ssh -i Andrew.pem ec2-user#55.55.44.33
Please help! I'm not picky, just any graphical text editor since using nano is a huge pain.
For remote editing, there are lots of options here: This answer, like any other, is sure to become outdated as more options enter the field.
For vim, the netrw module meets this need, and is shipped with the editor by default.
For emacs, this is available with TRAMP.
For the ATOM editor, see the remote-files plugin.
For IntelliJ, editing files on remote hosts is supported in the commercial edition.
For Eclipse, see the Remote System Explorer from the Target Management project.
I'd suggest starting with the editor you prefer and evaluating options from there. If you set up your SSH session to be able to authenticate directly to root (password auth is best disabled for root, but if you have sudo you can install RSA keys), then you'll be able to specify root as a target user for any of the above.
By contrast, if you really do need sudo, you still have options:
See Using tramp to open files sudoed to root on the Emacs wiki. New versions also support a ssh+sudo transport, meaning this wiki entry may already be out-of-date.
To help anyone that just need a quick command line text editor:
you can use vi:
vi file-name.txt
or nano:
nano file-name.txt
optionally use sudo if editing the file, eg:
sudo nano file-name.txt
Just modify the appropriate files on your local machine and scp the file into the remote machine.
scp <local_machine_path_to_file> remoteUser#remoteHostName:<filePath>
amazon now acquire Cloud9, which is a browser-based IDE that can edit your EC2.
https://aws.amazon.com/cloud9/
Today I found two products that can use sudo, they are
MobaXterm (free version) and SmarTTY
MobaXterm has a button in the file browser that enables sudo mode. You can view, create and edit files as a sudo user. Use this switch when necessary.
Unfortunately, this only works through the SCP protocol.
SmartTTY works differently. When you try to save a file that requires sudo, SmarTTY throws an error and immediately suggests trying to save the file with sudo
Of the two products, I recommend MobaXterm.
Sudo is for root privileges for that particular command. You will need to use root privileges to edit system files. Even on a local machine. If you don't like typing sudo every time, you can type sudo -s. You will change to root user and it will show you in terminal i.e. root#ip.... The $ sign will also change to #. Honestly, I prefer not going root, because it is easier to make irreversible mistakes with root privileges. I've made some mistakes and I'm talking from experience...
As far as the second part of your question goes, you can configure various text editors to sftp into your instance such as sublime.
You will have to use the .pem key file every time you ssh using terminal. This is because AWS takes security very seriously. You can put the key file in your home directory. That way you don't have to change directories every time you open up terminal.
You can also edit a local copy of files and then use FileZilla to transfer. Setting up FileZilla to work with your EC2 instance is straightforward. You can give vim a try since it colors your code and is more advanced than nano. Use the command vi or vim from terminal.
Happy SSH'ing ;).
ssh -X user#server.
You have to make appropriate setting for forwarding.
I use SFTP Net Drive SFTP, which let you create a virtual drive on your local computer that will map the remote file system accessible via SFTP protocol. After the map is created, you can use the editor of your preference.
You can use nano, vim, vi or many others. However if you want to edit with a graphical text editor you will have to create SFTP since Amazon does not support FTP. One way is to use filezilla to upload your files. Here is a video on using filezilla https://www.youtube.com/watch?v=VawBMj29g0o I suggest SSH though. Its fast and easy here is a video on that https://www.youtube.com/watch?v=O2-3HoRjBH4
I found a weird workaround for a GUI based text editor on AWS, I used Jupyter Notebook. If you have Anaconda installed on you instance, you follow the following steps
ssh onto your instance using ssh -i <location of your private key> <username>#<public DNS>
Start jupyter notebook on your instance using jupyter notebook --no-browser --port=8888
Open a new terminal window and ssh onto your jupyter notebook using ssh -i <location of your private key> -L 8212:localhost:8888 <username>#<public DNS>
Now you can open jupyter notebook at localhost:8212
Using the jupyter notebook environment, you can not only launch and run Ipython notebooks but also create and edit any files like a text editor.
would really like a graphical text editor
You cannot have a graphic editor, you need to use any editors like nano as you said or vim,emacs. Sudo would be required when you have to edit configuration files with root as owner.
To assist others with this same question, I would suggest jEdit. It is very capable, and it has a very rich plugin environment, language parsing, etc.
http://www.jedit.org
It has "always" supported sftp read and write of files with the sshConsole plugin.
I use it now on my AWS EC2 instance with the key pair supplied by AWS.
Lastly, it is not a good idea to edit files owned by root in the "production" environment.
Do your dev work in the AWS user's home folder so that you have full control of the source files. Then use a symlink to the actual server's file tree so you can serve it to yourself for testing. There are lots of controls in nginx and apache to limit who can view your dev site.
EDIT/UPDATE:
The NppFtp plugin to Notepad++ profides sftp access to AWS. I just tested it with the .pem file that they provided for my login at AWS.
For this, i'd suggest one of:
Learn and use emacs; it's quite powerful as far as textmode editors go.
Install your favourite graphical editor on the server and use X forwarding, 'ssh -X server.com'. This will allow you to launch the editor remotely, but have it display locally.
Most elegant in my opinion, use sshfs (https://github.com/libfuse/sshfs) to mount the remote directory locally, so you can work on the files directly using your favourite text editor.

Lynx file "/etc/lynx.lss" is not available

using cpanel server, setting a simple "lynx http://www.domain.com/script.php" command gives following error and I am unable to understand it.
Lynx file "/etc/lynx.lss" is not available.
the problem is the SHELL.
You can solve this problem via two ways:
1] I simply changed the sentence:
SHELL="/usr/local/cpanel/bin/jailshell"
in /var/spool/cron/account
to SHELL="/bin/bash"
2] You can copy file /etc/lynx.lss
to directory: /home/virtfs/account/etc
Both worked for me !
Wilhelm
You can create an empty (or not) style sheet file in a directory where you have write access, then explicitly point to that file on the lynx command-line:
lynx -lss=/path/to/my/lynx.lss ...
I enabled shell access for the account and it started working. The above answer seems to assume you have access to the entire server and can modify those files, if so then just enable shell access and you are set, but if you are on a shared hosting account basic cpanel and ftp access you may not be able to do it. Ask you hosting company if you can have shell access. Then decide what you can do depending on the answer they give you.
you can solve this issue by follow below process :-
Open this file
root#server [~]# vi /var/cpanel/exim.conf.deps
and append below entries and save it.
/etc/lynx.lss

Is there a way to directly edit files on a server?

Is there anyway to directly code on a server, meaning you open the file from the server and save it there?
Or is there any method faster than traditional ftp that automatically syncs to the server when you save locally?
Using SVN is a good option.
Read this: Combined SVN FTP system
If you're just talking about text files then some text editors support this, e.g. BBEdit, which can open and save directly to/from FTP/SFTP etc.