1

I wanted to create a new user on my digital ocean server and then log in as this user using SSH but I'm getting an access denied error. Here are the steps I tried.

On Local Machine:

#create a new key
ssh-keygen -b 1024 -f userblue -t dsa
chmod 600 userblue.pub

#copy the public key over to a temp dir on the target server using my root user/key
scp userblue.pub root@mytargetserver -i id_rsa:/tmp

Now I log into the target server as root so I can make a new user, and copy the public key to authorized_keys

#create a new user and make an .ssh dir for this user
useradd -m -d /home/userblue -s /bin/bash userblue 
su - userblue
cd /home/userblue
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

#move the public key I created and add it to authorized_keys
mv /tmp/userblue.pub /home/userblue/.ssh/
cat useable.pub >> /home/userblue/.ssh/authorized_keys

Now I log out and go back to my local machine, using the userblue private key to log in

ssh userblue@mytargetserver -i userblue

Permission Denied (publickey)

Any idea why I'm getting Permission Denied? I tried ssh with -vvv but it's completely Greek to me. Have no idea what to look for.

1

1 Answer 1

1

In my /etc/sshd file I had Match User but my new user I created wasn't in there, so that was why. After adding another ",User userblue" it worked!

You must log in to answer this question.

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