Control Web Panel
WebPanel => CentOS 7 Problems => Topic started by: stevland on June 28, 2018, 10:25:31 PM
-
I can't seem to find any information regarding my question.
I can connect to my server at root using SSH using key-based authentication.
But I am am also trying to setup SSH access for a non-root user on the server.
Shell access is checked ✓ under Edit User.
Ideally I would like to use a unique SSH key for this user, but I have no idea how to set that up.
In the meanwhile, I am trying to connect as that user. But I receive
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
If I try and connect using the root's key I receive
Server refused our key
What am I missing?
-
Nevermind. Figured it out. I'll share the solution for some other noob who is sure to ask the same question.
I just needed to create a keypair using ssh-keygen -f <username> which put username and username.pub in my user's /home/.ssh directory.
I then had to create a file called authorized_keys in the same directory and copy the contents of username.pub into it.
I then use the username file as the private key when connecting as username@domain.com from PuTTy/BitVise/MobaXterm/etc.
-
Thanks Stevland!
-
Thank you stevland for your reply.
I just want to make your answer more clear.
1. Create the .ssh directory in the /home/username first
2. Then create a key pair while logged in as root user using the command
ssh-keygen -t rsa -f /home/username/.ssh/<key_name>
This will result in two files in the /home/username/.ssh directory namely <key_name> and <key_name>.pub
Then add the contents of the key_name.pub file to the authorized_keys file using the command
cat /home/username/.ssh/<key_name>.pub> /home/username/.ssh/authorized_keys
Then you can use the username and the <key_name> file to login via ssh without any issues
This particularly applies to the cloud servers where the ssh access is allowed ony using the key files.