SSH - Can't get public key authentication working

I’m trying to set up SSH between my parent’s PC and my laptop so I can remotely access their PC to provide support when they run into trouble.

I followed this tutorial SDB:Configure openSSH - openSUSE, I know it’s outdated but it’s the only one I found.

I basically did the following steps.
On the remote PC (my parents PC) I started SSHD
I created a sshlogin group on the remote PC and made my dad’s account a member of the group.
I then proceeded to create the keys by running ssh-keygen on the client PC (my Laptop). I kept everything default for the moment except I used a passphrase when generating the keys. I then uploaded the public key using ssh-copy-id user@ssh.yourserver.org substituting the correct user and host. This created an authorized_key file on the remote PC.

The etc/ssh/sshd.config file on the remote PC looks like this

#    $OpenBSD: sshd_config,v 1.87 2012/07/10 02:19:15 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
#Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# 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

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys

#AuthorizedPrincipalsFile none

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

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
# ChallengeResponseAuthentication yes

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable support for the deprecated 'gssapi' authentication
# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included
# in this release. The use of 'gssapi' is deprecated due to the presence of
# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not susceptible to.
#GSSAPIEnableMITMAttack no

# 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

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation sandbox        # Default for new installations.
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem sftp    /usr/lib/ssh/sftp-server

# This enables accepting locale enviroment variables LC_* LANG, see sshd_config(5).
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
AllowTcpForwarding yes
Compression no
MaxAuthTries 6
PermitRootLogin no
PrintMotd yes
PubkeyAuthentication yes
RSAAuthentication no
Protocol 2
Port 22
AllowGroups sshlogin

# Example of overriding settings on a per-user basis
#Match User anoncvs
#    X11Forwarding no
#    AllowTcpForwarding no
#    ForceCommand cvs server


The problem is when I try ssh to the remote PC by running ssh user@server.org I get a prompt for a password. The password is not the passphrase used in the keygen but my dad’s user account password so it seems the SSH is not working. What am I doing wrong? I’m sure I’m missing something simple but just can’t see it.

Am supposed to copy the key.pub file to the remote PC too or is the authorized_key file enough?

The “authorized_key” file is sufficient.

Use:


ssh -v user@server.org

and post the output here (with code tags – use the “#” button on the editor box to generate the code tags).

Maybe, also provide the output, on the remote computer, from:


ls -ld / /home /home/user /home/user/.ssh

for the appropriate user. Messed up permissions can cause problems.

OK, will do. It will have to be tomorrow now.

The usual reason for this is that your keys, though generated and stored
remotely, are not being used for authentication. This usually happens the
first time because you forgot to load the key into the SSH agent. To
prove this, load it explicitly:

Code:

ssh -i ~/.ssh/id_rsa user@server.org #assuming ~/.ssh/id_rsa is your key

If that works, then load an SSH agent and load the file:

Code:

ssh-agent /bin/bash
ssh-add

Try again, and if this works, restart your terminal and see if it sticks.
Logout/login to see if it still sticks. You should get a passphrase
prompt (if a passphrase is set as you stated it was) but otherwise the
agent on openSUSE makes this pretty simple once the key is loaded.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…