17

While trying to communicate between my desktop Ubuntu 12.10 and Fedora 19 desktop, I am facing the error of Permission Denied (Public key).
I am able to login through ssh from fedora to Ubuntu, but not vice-versa.
I even performed telnet on both machines via port 22 and both machines are listening, but not through ssh. What to do? Any idea?

My sshd_config file is as follows:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile    %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
GSSAPIAuthentication no
GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

This is sshd_config of ubuntu system.

ssh -v fedora_machine

3
  • Possible duplicate of git ssh :Permission denied (publickey). Commented Aug 27, 2013 at 5:26
  • Which computer is that sshd_config from, Ubuntu or Fedora? Also, can you add a transcript of what happens when you ssh -v fedora_machine from the Ubuntu machine? Commented Aug 27, 2013 at 7:30
  • sshd_config is from ubuntu I just provided @DavidPurdue ssh -v fedora_mch in the question. Commented Aug 27, 2013 at 9:33

5 Answers 5

18

As you have noted, the Fedora box you are logging in to was not set up to allow password authentication, only public key authentication - this can be seen from the ssh -v result.

So one solution is to add password authentication, as you have done.

The other method would be to take the contents of ~/.ssh/id_rsa.pub on the Ubuntu box and add it to the file ~/.ssh/authorized_keys on the Fedora box.

Now that you have password authentication enabled, you can install the authorized key with this command on the Ubuntu box:

$ ssh-copy-id fedora_box
11

Sorry all, it appears to be my mistake. I did not have

PasswordAuthentication yes

on the Fedora machine's SSH configuration.

Solved it by enabling this. Thanks for your help.

1
  • AFAICT yes is the default value Commented Aug 17, 2015 at 9:09
3

For me I had to comment out ChallengeResponseAuthentication no ontop of having PasswordAuthentication yes on.

1
  • Yes, required on Ubuntu 16
    – Max
    Commented May 8, 2017 at 19:24
0

My issue was that I had multiple public keys and ssh-copy-id defaulted to the wrong one:

/usr/local/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/admin/.ssh/id_boot2docker.pub"

When I used the correct public key it worked:

ssh-copy-id -i ~/.ssh/id_rsa.pub remote-machine
0

I had the same problem with a new user account. I was still logged in as root in another shell. If you can access your server as root or a sudo user you can watch the ssh auth log via

tail -f /var/log/auth.log 

In my case the problem was the new_user was configured with an invalid shell.

user new_user not allowed because shell /bin/ is not executable

You must log in to answer this question.

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