Can Anyone explain about how to establish a connection to a same server with different private/rsa/identity using identity file.

Dani AI

Generated

Answering (and following 's clarification): for the same remote account the safe, standard pattern is that each source user has their own keypair and the remote account's ~/.ssh/authorized_keys contains all of the allowed public keys. That avoids sharing private credentials and makes auditing and revocation manageable. (ssh.com)

Quick, practical steps (client and server):

Generate a modern key and push the public key to the server:

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_muthu -C "muthu@client"
ssh-copy-id -i ~/.ssh/id_ed25519_muthu.pub remoteuser@server.example.com

Or append manually:

cat ~/.ssh/id_ed25519_muthu.pub | ssh remoteuser@server 'mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'

Always enforce permissions: private key 600, ~/.ssh 700, authorized_keys 600. OpenSSH will ignore private keys that are readable by others (the “UNPROTECTED PRIVATE KEY FILE” behavior). (simplified.guide)

Client-side selection: use multiple IdentityFile lines in the SSH config to connect to the same HostName with different identities. Example ~/.ssh/config:

Host server-key1
  HostName server.example.com
  User remoteuser
  IdentityFile ~/.ssh/id_ed25519_muthu

Host server-key2
  HostName server.example.com
  User remoteuser
  IdentityFile ~/.ssh/id_ed25519_colleague

Then use ssh server-key1 or ssh server-key2. (manpages.ubuntu.com)

About a “global” identity file on the source host: sharing a private key file across local users is both insecure and commonly rejected by OpenSSH due to permission checks. For central management of authorized keys on the server side use sshd_config options (AuthorizedKeysFile or AuthorizedKeysCommand) or a dedicated deployment account with restricted commands; note that client tools like ssh-copy-id write to the default authorized_keys and won’t update custom server-side locations automatically. (mankier.com)

Troubleshooting: run ssh -v/-vvv to see which key is offered, verify file ownership/permissions, and confirm the correct public key line exists in the server account's authorized_keys.

Recommended Answers

All 2 Replies

You want to connect as a new user or you want to connect as the same user with different credentials?

foe existing user only. How to make the identify file is global in source system,instead of user specific.

if I create a rsa key then the owner should be on my name.others not able to add their keys in the identity file which I was created. Is it possible to make single file for all users.?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.