How to allow ssh access using PubKeyAuthentication

hi every one
kindly guide me

Check SSH PasswordAuthentication

You should disable PasswordAuthentication and only allow access using PubkeyAuthentication to improve brute-force SSH security

Hello @MalikAamirAli Happy you are here

To allow public key authentication for ssh access you should go to https://SERVER_IP:8090/firewall/secureSSH → choose SSH Keys and paste your public key

How to create an ssh key in your PC/Laptop

## check existing ssh keys on your pc
$ ls -al ~/.ssh
## generate a new key for cyberpanel
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
## add key to ssh-agent
$ ssh-add ~/.ssh/id_rsa

To copy the public key

$ cat ~/.ssh/id_rsa.pub

paste it to cyberpanel as instructed above

2 Likes

Hello sir josephgodwinke thank you sir i hope you all away happy.
sir
i think mistke

r# ls -al ~/.ssh
total 20
drwx------ 2 root root 4096 Mar  3 10:28 .
drwx------ 7 root root 4096 Mar  3 10:28 ..
-rw------- 1 root root  652 Mar  4 10:38 authorized_keys
-rw------- 1 root root 2622 Feb 18 01:15 cyberpanel
-rw-r--r-- 1 root root  587 Feb 18 01:15 cyberpanel.pub
but $ user some error then agine and agine try 

$ ls -al ~/.ssh
reply
ls: cannot access '/home/amir/.ssh': No such file or directory

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
reply
Generating public/private rsa key pair.
Enter file in which to save the key (/home/amir/.ssh/id_rsa):

Enter file in which to save the key (/home/amir/.ssh/id_rsa): ssh-add ~/.ssh/                   id_rsa
Enter passphrase (empty for no passphrase):
enter putty gernate passkey syberpanel 
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "ssh-add ~/.ssh/id_rsa" failed: No such file or directory
:~$

so help plz
i am usint
putyy , ubuntu 20.04 ,on contabo
some comment use allread before this post
48 /etc/ssh/sshd_config
49 ls ~/.ssh/authorized_key
50 mkdir ~/.ssh
51 chmod 700 ~/.ssh
52 touch ~/.ssh/authorized_keys
53 chmod 600 ~/.ssh/authorized_keys
54 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
55 mkdir ~/.ssh
56 chmod 700 ~/.ssh
57 touch ~/.ssh/authorized_keys
58 chmod 600 ~/.ssh/authorized_keys
59 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
60 mkdir ~/.ssh
61 chmod 700 ~/.ssh
62 vi ~/.ssh/authorized_keys
63 cd ~/.ssh
64 ssh-keygen -t rsa -f cyberpanel -C root

This is uneccessary since at this point it shows you already have that folder with cyberpanel keys

Can you run the commands again here How to allow ssh access using PubKeyAuthentication - #2 by josephgodwinke and give the key any name like sshd instead of id_rsa

same issue
:~$ ls -al ~/.ssh
ls: cannot access ‘/home/malik/.ssh’: No such file or directory
$ ssh-keygen -t rsa -b 4096 -C “[email protected]
Generating public/private rsa key pair.
Enter file in which to save the key (/home/malik/.ssh/id_rsa): ssh-add ~/.ssh/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key “ssh-add ~/.ssh/id_rsa” failed: No such file or directory
:~$ cat ~/.ssh/id_rsa.pub

You are not a sudo user of this server. The steps are different:

## commands to correct permissions
## https://superuser.com/questions/530016/ssh-rsa-key-with-non-root-user#530017
$ chmod 600 ~/.ssh/authorized_keys2
$ chmod 600 ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh
## generate a new key for cyberpanel
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
## add key to ssh-agent
$ ssh-add ~/.ssh/id_rsa

hi sir

:~$ chmod 600 ~/.ssh/authorized_keys2
chmod: cannot access ‘/home/my user name/.ssh/authorized_keys2’: No such file or dire ctory
:~$ chmod 600 ~/.ssh/authorized_keys
chmod: cannot access ‘/home/my user name/.ssh/authorized_keys’: No such file or directory
:~$ ssh-keygen -t rsa -b 4096 -C “[email protected]
Generating public/private rsa key pair.
Enter file in which to save the key (/home/my user name/.ssh/id_rsa): ssh-add ~/.ssh/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key “ssh-add ~/.ssh/id_rsa” failed: No such file or directory
:~$

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.