0

Here is my problem:

  • I got two machines in the same network 192.168.122.0/24

my /etc/hosts :

192.168.122.100  toto
192.168.122.110  tata

if I type : ssh toto:

root@toto's password:
Permission denied (publickey,password).`

but If I type ssh toto@192.168.122.100 it works..

What is the problem?

5

You must specify the remote user, otherwise it will use the user that you are logged into locally.

For example:

ssh username@host

So, in your case you would use:

ssh toto@toto
  • 1
    If you do not specify a User (user@host), you will use the user specified within your ~/.ssh/config file, or whichever user you are on the current machine (in this case, you're root on the local machine when ssh'ing). – earthmeLon May 27 '16 at 21:23
1

First, did you check these directives on /etc/ssh/sshd_config (toto host)?

AllowUsers root toto
PermitRootLogin yes

If it is a production environment, I strongly suggest set these directives at this way:

AllowUsers toto
Port 2233
PermitRootLogin no

Avoid root access and design other port than 22. It's safer.

If you want to access local network hosts without password prompt, just follow these steps bellow (let's suppose totXX=host client, totYY=host server ssh):

  1. Create the same user in all machines (Ex: toto) with the same password;

  2. Generate the public key on totXX

    # may output a message like this:
    toto@totXX:~> ssh-keygen -t rsa 
    Generating public/private rsa key pair.   
    Enter file in which to save the key (/home/toto/.ssh/id_rsa):  
    Created directory '/home/toto/.ssh'.  
    Enter passphrase (empty for no passphrase):  
    Enter same passphrase again:  
    Your identification has been saved in /home/toto/.ssh/id_rsa. 
    Your public key has been saved in /home/toto/.ssh/id_rsa.pub. 
    The key fingerprint is:
    3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 toto@totXX
    
  3. Create ~/.ssh directory on totYY

    toto@totXX:~> ssh toto@totYY mkdir -p .ssh
    toto@totYY password: 
    
  4. Put totXX public key on totYY:

    toto@totXX:~> cat .ssh/id_rsa.pub | ssh toto@totoYY 'cat >>  ssh/authorized_keys'  
    toto@totoYY password: 
    
  5. Restart ssh service on totYY:

    toto@totXX:~> sudo service ssh restart
    
  6. If everything is ok, the password won't be requested on ssh access.

    toto@totoXX:~> ssh toto@totoYY  
    toto@totYY:~>
    

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.