3

I'm using ubuntu system to login to remote server using ssh. SSH is configured in my system and I can see my public ssh key but when I try something like ssh xx.xx.xx.xx it throws error Permission denied (publickey).

For the IP address which I'm trying to access, ssh username is ec5-user without any password.

Do I have to switch to that user in my ubuntu terminal before using ssh xx.xx.xx.xx ? Using putty, I'm able to login from windows system.

If I do ssh-keygen -lf ~/.ssh/id_rsa.pub, it gives soething like

2048 aa:b5:51:76:de:42:12:78:a1:ff:9e:74:d8:7d:59:24  amit@amit-Inspiron-N5010 (RSA)
1

Check .ssh folder permission (run ls -laR ~/.ssh):

.ssh folder should have 700, while private key 600 and the public one can have 644.

Moreover, you can have more information about the problem running ssh with full debug logs

ssh -vvv ...
| improve this answer | |
  • Here is the output of ls -laR ~/.ssh /home/amit/.ssh: total 52 drwx------ 3 amit amit 4096 Jul 29 20:16 . drwxr-xr-x 49 amit amit 20480 Jul 30 12:24 .. -rw-rw-r-- 1 amit amit 0 Jun 2 15:26 authorized_keys -rw------- 1 amit amit 1766 Jan 26 2015 id_rsa -rw-r--r-- 1 amit amit 402 Jun 2 15:31 id_rsa.pub -rw-r--r-- 1 amit amit 12288 Jul 29 20:17 .id_rsa.pub.swp -rw-r--r-- 1 amit amit 3538 Jul 8 11:26 known_hosts drwxrwxr-x 3 amit amit 4096 Jun 2 14:41 retailon_referral – amitshree Jul 30 '15 at 9:43
  • According to the output of ls -laR ~/.ssh `/home/amit/.ssh: is having permission 700. Should I uninstall completely SSH and install it again? – amitshree Jul 30 '15 at 9:49
  • It is quite hard to read you comment, next time please format the code. Anyway, permissions look fine. What about the output of ssh -vvv ... (full debug infos)? – clobrano Jul 30 '15 at 10:08
  • OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014' debug1: Reading configuration data /etc/ssh/ssh_config` debug1: /etc/ssh/ssh_config line 19: Applying options for * ssh: Could not resolve hostname ...: Name or service not known – amitshree Jul 30 '15 at 10:57
  • Name or service not known means that it could not find the machine you are trying to connect to, it is not a problem of permissions. Moreover, I will try to follow Daniel's suggestions – clobrano Jul 30 '15 at 11:50
1

You're trying to ssh to ec5-user@xxx.xxx.xxx.xxx. OK, they way ssh works is as follows:

ssh xxx.xxx.xxx.xxx = ssh [my username]@xxx.xxx.xxx.xxx

ssh bob@xxx.xxx.xxx.xxx = ssh bob@xxx.xxx.xxx.xxx

So, you need to either log in to the same username, or you need to specify what username you're trying to ssh to.

| improve this answer | |
0

If the comments above are correct that you are indeed getting Could not resolve hostname, this means that Ubuntu has no idea how to find the hostname you're giving it. Can you log in via the IP address?

If using the IP address works fine and you're having issues connecting to a hostname (which the error seems to indicate), you can modify your /etc/hosts file to include the node you are trying to connect to. Just enter the hostname and IP address you want it tied to like so:

EXAMPLE

   127.0.0.1       localhost
   192.168.1.10    foo.mydomain.org       foo
   192.168.1.13    bar.mydomain.org       bar
   146.82.138.7    master.debian.org      master
   209.237.226.90  www.opensource.org

Fields of the entry are separated by any number of blanks and/or tab characters. Text from a "#" character until the end of the line is a comment, and is ignored. Host names may contain only alphanumeric characters, minus signs ("-"), and periods ("."). They must begin with an alphabetic character and end with an alphanumeric character. Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, localhost).

Source: http://manpages.ubuntu.com/manpages/lucid/man5/hosts.5.html

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.