LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   using keys for ssh connection (https://www.linuxquestions.org/questions/linux-newbie-8/using-keys-for-ssh-connection-4175513975/)

sniper8752 08-08-2014 08:27 AM

using keys for ssh connection
 
I am trying to create public/private keys to connect to my ssh server. I use puttygen/putty, and when I connect, it tells me that the "server refused our key". I ran the following commands:
Code:

# chmod 700 ~/.ssh
# chmod 600 ~/.ssh/authorized_keys

and added this line to the sshd_config file:
Code:

AuthorizedKeysFile %h/.ssh/authorized_keys
But I still get the same error. The key in the authorized_keys file is all on one line.

EDIT: By the way, I followed this tutorial: https://www.digitalocean.com/communi...nnect-to-a-vps

AlucardZero 08-08-2014 09:32 AM

what's in /var/log/secure or /var/log/auth.log about it? (you also should mention what distro and version you are running)

sniper8752 08-08-2014 04:02 PM

Raspbian. It's for my Raspberry Pi.
Code:

User ftpuser from computer not allowed because not listed in AllowUsers
input_userauth_request: invalid user ftpuser [preauth]

In sshd_config, I have AllowUsers ftpuser.

sniper8752 08-10-2014 02:26 PM

Anybody have any ideas?

kbnuts 08-10-2014 04:23 PM

Well you could take out the allowusers directive and see if the lockdown is causing it and it's a syntax issue.

sniper8752 08-10-2014 07:26 PM

I still get the error that the server refused the key.

keefaz 08-10-2014 07:30 PM

ftpuser is in /etc/passwd in the server? (grep ftpuser /etc/passwd)

sniper8752 08-10-2014 07:35 PM

yes; /var/www:/bin/bash

For sshd_config:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys

keefaz 08-10-2014 07:46 PM

Are you able to connect to the server with putty using a password?

sniper8752 08-10-2014 09:30 PM

yes

keefaz 08-11-2014 08:24 AM

You did run these commands as root ?
Code:

# chmod 700 ~/.ssh
# chmod 600 ~/.ssh/authorized_keys

.ssh dir needs to be in /var/www according to output of greping ftpuser in passwd file
and permissions need to be set as ftpuser

sniper8752 08-11-2014 08:34 AM

so .ssh should be in /var/www? why is it in the user's home directory?
I did run these, but will run them again. Should the user owner be ftpuser, as well as the group owner?

keefaz 08-11-2014 10:58 AM

Quote:

Originally Posted by sniper8752 (Post 5218799)
so .ssh should be in /var/www? why is it in the user's home directory?

Yes /var/www is home user dir for ftpuser according to passwd
.ssh should be in user dir according to sshd_config (%h/.ssh)
Quote:

Originally Posted by sniper8752 (Post 5218799)
Should the user owner be ftpuser,

Yes
Quote:

Originally Posted by sniper8752 (Post 5218799)
as well as the group owner?

Yes, see which group ftpuser belongs to in passwd for fptuser line (4th field)
or more simple, as root : "id ftpuser"

sniper8752 08-11-2014 02:59 PM

What if I want to allow other users to login?

keefaz 08-11-2014 06:23 PM

Eventually users can login to ftpuser account if they have their public keys appended to /var/www/.ssh/authorized_keys file, then login as: ssh ftpuser@server

But it has some security concerns for sure.

Anyway if you tell what specifically your plan is from the start, you'll get more productive answers I think


All times are GMT -5. The time now is 04:17 AM.