Can Coda 2 edit a file that the current user does not have permissions for?

On a couple of servers I work on, despite having access to edit files and all else, there is the occasional need to gain elevated privileges (like running sudo) with the file to actually save the changes.

That said I like working with my files in Coda 2 and not the Terminal directly. So is there either a way to sudo the file open through the explorer when viewing the remote files, or is there a way to trigger a file to open through the built-in terminal in Coda 2 so I can make the edits, save, and move on.

Currently when I double click on a file to open it, if I would need elevated privileges, the file will open only in a read-only state.


Solution 1:

No, it can not. Coda 2, Coda, and Transmit all allow you to SFTP into a box, but when you try to access a file that is not in your user's accessible range, you have to log out and then log back in as a user who can.

I use Transmit and Coda 2 constantly and just have made it to where I am only signing in as root because I ended up having to log in as different users to access one file and then a different file.

I wish there was another way around it, like being able to have Transmit, Coda, or Coda 2 push some kind of command to the server or something but it isn't possible in any of the Apps current states. I would highly recommend doing a feature request to them, I can't see how we would have been the only people who have ever wanted this.

I would recommend trying to contact them through their twitter account. They are pretty cool guys and have responded to things like this before on Twitter.

http://twitter.com/#!/panic

I know it wasn't the answer you were probably looking for but I hope it helps.

Solution 2:

An "open as sudo" command has still not been implemented in Coda2 so I have been using the following workaround to be able to edit a file that belongs to another user or root without having to use something as painful as vi

  1. Open a terminal connection in a tab in the SFTP connection.
  2. Run a chown command on the file to the user you can login as (this user must have sudo privs). Be sure to note who original user was.

    sudo chown your-user-name path/to/file

  3. Navigate to the file and click to open it, edit what you need and click save and close the file.

  4. Go back to the terminal window and chown it back to the original user:

    sudo chown original-user-name path/to/file

Obviously this is not the ideal situation, but it does make it so you can use all the awesomeness of Coda to edit the file instead of vi or other editors built into the command line.