5

The remote server requires a private key and passphrase for authentication. I'm trying to connect to the server as root (on that server) from Nautilus running on behalf of my non-root account on my local Ubuntu desktop. The private key that is needed for authentication is not located in ~/.ssh (I've already got other keys there) but I have it in another directory.

In addition to the obvious approach, I tried putting root@server in the "Server" field and leaving "User name" and "Password" fields blank, putting the passphrase in the "Password" field, but it still says "Permission denied" and it doesn't ask for the private key at any point.

I also tried ssh-add path/to/privatekey, but it says "Could not open a connection to your authentication agent.", however I'm not sure if ssh-add is even relevant here.

I can ssh into the server from the terminal just fine with

ssh -i <...>/id_rsa root@server

and answering the passphrase question that follows.

4
  • "The remote server requires a private key and passphrase for authentication." ? this doesn't make sense. The remote server can't require a 'private key'. (Or I'd be happy to learn...) Dec 7, 2012 at 12:18
  • @martin-mystere It meant that the remote server requires a private key from me for auth, just like it requires a passphrase from me, of course. Thanks for deleting your "answer" anyways. Dec 7, 2012 at 12:52
  • We could use a little extra information from you. What version of Nautilus are you using? What kind of encryption do you use to generate your keys? I just made a small test setup and I could replicate your problem if I used ECDSA encryption instead of RSA. I'm not sure what encryptions Nautilus supports. Dec 7, 2012 at 13:03
  • @ChristianSkjødt Provided some more details. The encryption is RSA. Dec 7, 2012 at 13:26

4 Answers 4

9

The short version (skip the script) of Marcin Kaminski's solution is

ssh-agent
ssh-add /path/to/your/private_key
nautilus sftp://user@server

. I think it's easier to start with, to test if the solution works. I had the same problem after setting PasswordAuthentication no in /etc/ssh/sshd_config and these three commands solved my problem.

1
  • 1
    thanks for simplifying that answer for me. This works perfectly :-)
    – gannex
    Sep 18, 2016 at 3:58
6
+50

I don't see why key selection dialogue should appear at all. It's up to the server to offer authentication methods it's willing to accept and up to the client to provide the credentials.

One of the most common methods for providing those details is using the ssh-agent which you don't appear to be running. This is a little snippet I've put in my ~/.profile to make sure my ssh-agent is always running:

run_ssh_agent() {
  ssh-agent | grep -vi 'agent pid' > ~/.ssh-agent
  . ~/.ssh-agent
}

if [[ -f ~/.ssh-agent ]]; then
  . ~/.ssh-agent
  if [[ -n ${SSH_AGENT_PID} ]]; then
    if ! ps -p ${SSH_AGENT_PID} | grep 'ssh-agent' &>/dev/null; then
      run_ssh_agent
    fi
  fi
else
  run_ssh_agent
fi

Put the code there, log out of your X session, log back in, open a terminal and add your key to your agent:

ssh-add /path/to/your/private_key

Verify that it's added by running ssh-add -l and connect to the server using Nautilus without providing the password.

1

I could connect to my server in Nautilus (Ubuntu 12.04) using a private key by doing the following:

  • In Nautilus, select menu: "File" -> "Connect to Server..."
  • Change "Type:" to "SSH"
  • Enter the address of the server in the "Server:" field (omitting username@)
  • Enter your user name after "User name:" but leave the password field empty.

When you hit "Connect" a dialog should appear telling you a password is needed to unlock the key. In my case the key was not the default "~/.ssh/id_rsa", so communication between the SSH client and server must have revealed to Nautilus what key should be used.

After entering the password, a new Nautilus window opened where I chould browse the files on my server. In the left pane I now have a shortcut "SFTP for user on server" which I can also use to u(n)mount the server file system.

3
  • Where did you put that key instead? I put my key file into ~ and even changed its permissions to 777 but Nautilus still doesn't seem to be able to locate it. Dec 7, 2012 at 13:46
  • It's stored in my ssh folder but with another file name: ~/.ssh/id_rsa_example.
    – jmidgren
    Dec 12, 2012 at 10:56
  • Changing the permissions will probably only make things worse. Your private key must only be available to you and should thus have 600 permissions. Also check out the permissions of your ~/.ssh folder and your home folder. Depending on if you are the only member of the group that owns those folders or not, you may have to restrict access to group members as well (e.g. 700 on ~/ and ~/.ssh).
    – jmidgren
    Dec 12, 2012 at 11:07
0

If I understand correctly, you are using public-key authentication but your private key requires a password to unlock, and the connection attempt is failing since you are apparently not prompted for the password protecting the key.

This question is slightly different, but the first answer seems to describe the same situation. However, it implies that the password dialog should just work. Perhaps it will provide a starting point though?

Since you say it works if you use ssh in a terminal, presumably it is not something like the remote host identity changing, which I think can cause silent failures in nautilus.

1
  • Thanks but I'd rather expect a key location dialog, which never appears. Please see the edits I made to provide more details (one is that I'm trying connect as root). Dec 7, 2012 at 13:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .