🌐 Detecting your location…
📢 Advertisement — Configure AdSense in Appearance → Customize → AdSense Settings

GitHub पर अनुमति अस्वीकृत सार्वजनिक कुंजी SSH त्रुटि को कैसे ठीक करें

⏱️2 min read  ·  402 words

त्रुटिgit@github.com: अनुमति अस्वीकृत (publickey)। घातक: दूरस्थ रिपॉजिटरी से नहीं पढ़ा जा सका इसका मतलब है कि GitHub ने आपके SSH प्रमाणीकरण को अस्वीकार कर दिया है। Git सेट करते समय यह एक सामान्य अवरोधक है। यहां बताया गया है कि इसे पूरी तरह से कैसे ठीक किया जाए।

इस त्रुटि का क्या अर्थ है

GitHub आपको SSH पर पुश/पुल के लिए प्रमाणित करने के लिए SSH कुंजियों का उपयोग करता है। “अनुमति अस्वीकृत (पब्लिककी)” का अर्थ है कि GitHub आपकी पहचान सत्यापित नहीं कर सका – आमतौर पर क्योंकि आपके पास कोई SSH कुंजी नहीं है, कुंजी आपके GitHub खाते में नहीं जोड़ी गई है, या SSH एजेंट इसका उपयोग नहीं कर रहा है।

चरण 1: मौजूदा एसएसएच कुंजियों की जांच करें

ls -la ~/.ssh
# Look for: id_ed25519.pub or id_rsa.pub

# If you see .pub files, you may already have a key — skip to Step 3

चरण 2: एक नई SSH कुंजी उत्पन्न करें

# Ed25519 is the modern recommended algorithm
ssh-keygen -t ed25519 -C "your_email@example.com"

# Press Enter to accept default location (~/.ssh/id_ed25519)
# Optionally set a passphrase for extra security

# For older systems without Ed25519 support:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

चरण 3: SSH एजेंट

# Start the ssh-agent
eval "$(ssh-agent -s)"
# Agent pid 12345

# Add your key
ssh-add ~/.ssh/id_ed25519

# On macOS, store passphrase in keychain
ssh-add --apple-use-keychain ~/.ssh/id_ed25519

में कुंजी जोड़ें चरण 4: सार्वजनिक कुंजी को GitHub

# Copy your PUBLIC key (.pub — never share the private key!)
cat ~/.ssh/id_ed25519.pub

# macOS: copy directly to clipboard
pbcopy < ~/.ssh/id_ed25519.pub

# Linux:
xclip -sel clip < ~/.ssh/id_ed25519.pub

में जोड़ें फिर GitHub में:सेटिंग्स, फिर SSH और GPG कुंजियाँ, फिर नई SSH कुंजी. सार्वजनिक कुंजी चिपकाएँ और सहेजें।

चरण 5: कनेक्शन का परीक्षण करें

ssh -T git@github.com

# Success looks like:
# Hi username! You've successfully authenticated,
# but GitHub does not provide shell access.

# The "does not provide shell access" message is NORMAL and means it worked!

सामान्य कारण 1: SSH के बजाय HTTPS रिमोट का उपयोग करना

# Check your remote URL
git remote -v
# origin  https://github.com/user/repo.git  ← HTTPS, not SSH!

# Switch to SSH
git remote set-url origin git@github.com:user/repo.git

# Verify
git remote -v
# origin  git@github.com:user/repo.git (fetch)

सामान्य कारण 2: एजेंट में कुंजी लोड नहीं है

# List keys currently in the agent
ssh-add -l
# "The agent has no identities" means no key is loaded

# Add your key
ssh-add ~/.ssh/id_ed25519

# Make it persistent — add to ~/.ssh/config:
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519
  AddKeysToAgent yes
  UseKeychain yes   # macOS only

सामान्य कारण 3: ग़लत कुंजी अनुमतियाँ

# SSH refuses keys with loose permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519       # private key
chmod 644 ~/.ssh/id_ed25519.pub   # public key
chmod 600 ~/.ssh/config

वर्बोज़ आउटपुट के साथ डिबगिंग

# See exactly what SSH is doing
ssh -vT git@github.com

# Look for lines like:
# "Offering public key: ~/.ssh/id_ed25519"  ← key is being tried
# "Authentications that can continue: publickey"  ← GitHub wants a key
# If your key isn't offered, it's not in the agent or config

अक्सर पूछे जाने वाले प्रश्न

प्रश्न: क्या मुझे Ed25519 या RSA का उपयोग करना चाहिए?
उ: Ed25519 – यह RSA से अधिक सुरक्षित और तेज़ है। RSA (4096-बिट) का उपयोग केवल उन पुराने सिस्टमों के लिए करें जो Ed25519 का समर्थन नहीं करते हैं।

प्रश्न: .pub फ़ाइल और दूसरी फ़ाइल में क्या अंतर है?
A: id_ed25519.pub क्या आपकी सार्वजनिक कुंजी है – साझा करने के लिए सुरक्षित, इसे GitHub में जोड़ें। id_ed25519 (कोई एक्सटेंशन नहीं) आपकी निजी कुंजी है – इसे कभी साझा न करें, इसे कभी प्रतिबद्ध न करें।

प्रश्न: यह पहले काम करता था लेकिन अचानक विफल हो जाता है। क्यों?
उ: एसएसएच-एजेंट अक्सर रिबूट के बाद चाबियाँ खो देता है। जोड़ेंAddKeysToAgent yes to ~/.ssh/config, या फिर से चलाएँssh-add. MacOS पर,UseKeychain yes इसे सतत बनाता है.

प्रश्न: क्या मैं एक ही कुंजी का उपयोग अनेक मशीनों पर कर सकता हूँ?
उ: आप कर सकते हैं, लेकिन सर्वोत्तम अभ्यास यह है कि प्रत्येक उपकरण के लिए एक अलग कुंजी हो। इस तरह, यदि एक मशीन से छेड़छाड़ की जाती है, तो आप दूसरों को प्रभावित किए बिना GitHub से केवल उस कुंजी को रद्द कर देते हैं।

प्रश्न: GitHub के लिए HTTPS या SSH?
उत्तर: SSH बार-बार क्रेडेंशियल दर्ज करने से बचता है और एक बार सेट हो जाने के बाद सुविधाजनक होता है। व्यक्तिगत एक्सेस टोकन के साथ HTTPS एकबारगी उपयोग या SSH को ब्लॉक करने वाले प्रतिबंधित नेटवर्क के लिए आसान है।

निष्कर्ष

“अनुमति अस्वीकृत (पब्लिककी)” का अर्थ है कि GitHub आपकी SSH कुंजी को प्रमाणित नहीं कर सका। ठीक अनुक्रम: के साथ एक कुंजी उत्पन्न करें , इसेssh-keygen -t ed25519के साथ एजेंट में जोड़ें , GitHub में .pub कुंजी जोड़ें, औरssh-addके साथ परीक्षण करें . यदि यह अभी भी विफल रहता है, तो जांचें कि आपका रिमोट एसएसएच (एचटीटीपीएस नहीं) का उपयोग करता है और कुंजी अनुमतियां सही हैं। वर्बोज़ ध्वजssh -T git@github.com सटीक रूप से पता चलता है कि प्रमाणीकरण कहां टूटता है।ssh -vT सटीक रूप से पता चलता है कि प्रमाणीकरण कहां टूटता है।

✍️ Leave a Comment

Your email address will not be published. Required fields are marked *

🌐 Read in:🇩🇪 Deutsch🇧🇷 Português🇸🇦 العربية🇮🇳 हिन्दी🇧🇩 বাংলা