1

I connect to my work machine over SSH. Sometimes I transfer files back and forth using using Nautilus' "Connect to Server" feature. Sometimes I change to the root user and run commands. But I cannot for the life of me figure out how to do both.

If I want to transfer files, I connect to the following server from nautilus:

sftp://andreas@work/home/andreas

The SSH configs are set up to NOT allow you to log in as root (moreover, root doesn't even have any entries in the authorized_users file). However, if I want to log in is root, since andreas is in the sudoers group, I can do like this:

andreas@home:~$ ssh andreas@work
Welcome to Ubuntu 14.04.1 LTS
andreas@work:~$ su
Password: [entered password]
root@work:/home/andreas#

The problem is, how do I combine these two, allowing me to browse the remote file system over an SSH connection, but as root (a different user than the one I logged in with, in this case, andreas)?

  • I don't think you can. The sftp backend can't do su, so to browse as root you should be able to login as root. – Rmano Nov 12 '14 at 9:27
  • @Rmano Does SFTP use SSH, or does it have its own protocol? If it is the former, couldn't it use an existing tunnel or "continue off" after the existing SSH has authenticated as root? – IQAndreas Nov 12 '14 at 20:19
  • I'm not an expert --- but when you use su in the ssh connection, you have a shell with superuser privileges --- ssh is completely oblivious to that. Now, I do not know if you can start some strange tunnel from the root shell to do what you want. – Rmano Nov 12 '14 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.