1

I'm trying to create a new user in ubuntu with keybased authentication and to configure Github actions (via ssh) to deploy any new change done on my branch, however am stuck with SSH connection to the server which constantly throws error Permission denied. (publickey) Screenshot below.

I have admin access to the server, however issue is only for new users created which constantly throws error Permission denied. (publickey)

Following is how am trying to connect to server from local machine (mac)
ssh SpiderServer
user@hostname: Permission denied (publickey).

//my ~/.ssh/config file contains the following
Host SpiderServer
HostName ip-address-of-the-server
Port 22
User username
IdentityFile /Users/hs/.ssh/cert.pem

with verbose trace enabled, following is the outcome:

❯ ssh UW1003 -v
OpenSSH_9.0p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/hs/.ssh/config
debug1: /Users/hs/.ssh/config line 9: Applying options for UW1003
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to XXX.XXX.XX.XXX [XXX.XXX.XX.XXX] port 22.
debug1: Connection established.
debug1: identity file /Users/hs/.ssh/UW1003.pem type -1
debug1: identity file /Users/hs/.ssh/UW1003.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3
debug1: compat_banner: match: OpenSSH_8.9p1 Ubuntu-3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to XXX.XXX.XX.XXX:22 as 'githubdeployment'
debug1: load_hostkeys: fopen /Users/hs/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:R3a/mQVBiXfnkJ6Vive8+TCeffMSkTxQgHsm3EKeQG8
debug1: load_hostkeys: fopen /Users/hs/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'XXX.XXX.XX.XXX' is known and matches the ED25519 host key.
debug1: Found key in /Users/hs/.ssh/known_hosts:8
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /Users/hs/.ssh/UW1003.pem  explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: kex_input_ext_info: [email protected]=<0>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/hs/.ssh/UW1003.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

Attempt 1: via ssh-keygen command

Steps that I followed (Failed)

  1. Generated key pair using ssh-keygen -t rsa -b 4096 in the remote server
  2. cat <path/to/public/key> >> ~/.ssh/authorized_keys
  3. Downloaded the id_rsa to my local system (mac) as .pem file and tried connecting to server, but it threw Permission denied. (publickey) error.

Attempt 2: via AWS Key pair

  1. Went to AWS Key pair
  2. Generated RSA (.pem format)
  3. Downloaded the private key to my local system (mac) as .pem file and tried connecting to server, but it threw Permission denied. (publickey) error.
Following are my ubuntu server configurations related to ssh
PasswordAuthentication no
KbdInteractiveAuthentication no
AuthenticationMethods publickey
UsePAM no
StrictModes yes
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
AllowUsers spiderman

Things that I tried so far

  1. Copied the id_rsa and id_rsa.pub of the existing user via which I can access the remote server to the new user created (path /home/spiderman./ssh)
  2. Changed the access level to 0400 and 0600 to both the id_rsa and id_rsa.pub

I'm I missing anything?

1 Answer 1

1

Fixed! The issue was with the permissions. I just reprovisioned the permission and that worked!

Entity permission
.ssh directory 700 (drwx------)
public keys 644 (-rw-r--r--)
private keys 600 (-rw-------)
authorized_keys 600 (-rw-------)

You must log in to answer this question.

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