मुख्य सामग्री पर जाएँ
Skillpedia
डिप्लॉय और क्लाउड (DevOps)7.4k · #13247

ssh-doctor

यह क्या करती है

यह स्किल macOS पर SSH की समस्याओं की जाँच का चरण-दर-चरण तरीका बताती है, जैसे प्रमाणीकरण से पहले कटने वाले कनेक्शन। यह उन लोगों के लिए है जो अपने Mac का प्रबंधन करते हैं और जिनके लिए रिमोट लॉगिन चलना ज़रूरी है।

कब इस्तेमाल करें

  • ✓जब SSH कनेक्शन लॉगिन करने से पहले बंद हो जाता है।
  • ✓जब लगता है कि रिमोट लॉगिन चालू है पर फिर भी इस्तेमाल नहीं हो पा रहा।
  • ✓जब आपको स्थानीय या रिमोट Mac पर SSH की जाँच करनी है।

Skill का लिंक

https://github.com/steipete/agent-scripts/blob/main/skills/ssh-doctor/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/steipete/agent-scripts/blob/main/skills/ssh-doctor/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मैं अपने Mac से SSH नहीं कर पा रहा। कनेक्ट होता है और लॉगिन माँगने से पहले बंद हो जाता है। पता कीजिए क्यों।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट पहले Mac की स्थानीय जाँच करता है, फिर सर्वर कॉन्फ़िगरेशन और सुनने वाला पोर्ट, और उसके बाद ही नेटवर्क पाथ। वह सीक्रेट नहीं छापता, और SSH सर्वर फ़ाइल बदलने से पहले संदिग्ध कॉन्फ़िग लाइनें बताता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

SSH Doctor

Use when SSH connects then closes before auth, Remote Login seems advertised but unusable, or local/remote Mac SSH needs diagnosis.

Rules

  • Do not print secrets, tokens, full env, or broad secret grep output.
  • Validate locally first: loopback failure means server-side sshd/launchd/config; loopback success plus remote failure means network/firewall/filter/listen path.
  • Report suspicious config lines before changing /etc/ssh/sshd_config.
  • Prefer non-interactive SSH:
ssh -o RequestTTY=no -o RemoteCommand=none HOST 'hostname; id -un'

Baseline

hostname; id -un; sw_vers
ipconfig getifaddr en0
ipconfig getifaddr en1 2>/dev/null || true
ipconfig getifaddr en7 2>/dev/null || true
sudo systemsetup -getremotelogin
sudo systemsetup -setremotelogin on
sudo launchctl print system/com.openssh.sshd 2>&1 | head -80
sudo launchctl kickstart -k system/com.openssh.sshd
sudo lsof -nP -iTCP:22 -sTCP:LISTEN
nc -vz 127.0.0.1 22
ssh -4 -F /dev/null -o RequestTTY=no -o RemoteCommand=none USER@127.0.0.1 'hostname; id -un'

Use BatchMode=yes only when password fallback would hang or prompt.

Config

sudo sshd -T 2>&1 | egrep -i '^(allowusers|denyusers|allowgroups|denygroups|listenaddress|maxstartups|logingracetime|usepam|passwordauthentication|pubkeyauthentication|authenticationmethods)'
sudo egrep -n '^[[:space:]]*(AllowUsers|DenyUsers|AllowGroups|DenyGroups|Match|MaxStartups|LoginGraceTime|ListenAddress|AuthenticationMethods|UsePAM|PasswordAuthentication|PubkeyAuthentication)\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/* 2>/dev/null || true

Suspicious:

  • DenyUsers matching target user
  • restrictive AllowUsers / AllowGroups
  • Match block accidentally applying
  • tiny MaxStartups
  • tiny LoginGraceTime
  • ListenAddress missing target interface

Logs

sudo log show --last 30m --predicate 'process == "sshd" OR process == "launchd"' --style compact | tail -160

Important Mac symptom:

  • client: kex_exchange_identification: Connection closed by remote host
  • server log: Could not create new instance of inetd service: 67: Too many processes
  • launchctl print system/com.openssh.sshd: high copy count
  • many sshd-session: USER processes parented by PID 1

This means launchd accepted TCP but refused to spawn more sshd inetd copies.

Stale sshd-session Fix

Inspect first:

sudo launchctl print system/com.openssh.sshd 2>&1 | egrep 'active count|copy count|state =|last exit code|runs ='
ps -axo pid,ppid,uid,user,state,lstart,etime,comm,args | awk '/sshd-session:/ && !/awk/ {print}'
sudo lsof -nP -c sshd-session -iTCP 2>/dev/null | head -120

If stale sessions are clearly stranded and blocking new SSH, terminate by selected command-line match:

ps -axo pid=,args= | awk '/sshd-session: / && !/awk/ {print $1}' | xargs sudo kill -TERM
sleep 2
ps -axo pid=,args= | awk '/sshd-session: / && !/awk/ {print}'

If TERM leaves blockers, re-check ownership and active shells before using KILL.

Firewall

Only after loopback works but remote fails:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps | grep -i ssh -A2 -B2 || true
sudo pfctl -sr 2>/dev/null | head -80
sudo pfctl -si 2>/dev/null | head -80

Also check listen address and target interface:

ifconfig | awk '/^[a-z0-9]+:/{iface=$1; sub(":","",iface)} iface ~ /^en[0-9]+$/ && /inet / {print iface, $2}'
sudo lsof -nP -iTCP:22 -sTCP:LISTEN

OP Profile Block

If asked to ensure ~/.profile has a Codex-managed OP_SERVICE_ACCOUNT_TOKEN copied from another host:

  • verify exact variable/markers without printing value
  • copy only the matching line/block
  • redirect through a chmod 600 temp file
  • never echo the token

Presence check:

awk 'BEGIN{b=0;e=0;x=0} /BEGIN Codex-managed OP_SERVICE_ACCOUNT_TOKEN/ {b=1} /END Codex-managed OP_SERVICE_ACCOUNT_TOKEN/ {e=1} /^[[:space:]]*(export[[:space:]]+)?OP_SERVICE_ACCOUNT_TOKEN=/ {x=1} END{print "marker_begin", b; print "marker_end", e; print "exact_var", x}' ~/.profile

Append from remote host:

tmpfile=$(mktemp /tmp/codex-op-token.XXXXXX)
chmod 600 "$tmpfile"
ssh -o RequestTTY=no -o RemoteCommand=none HOST 'awk '\''/^[[:space:]]*(export[[:space:]]+)?OP_SERVICE_ACCOUNT_TOKEN=/ {print; exit}'\'' ~/.profile' > "$tmpfile"
if [ -s "$tmpfile" ]; then
  {
    printf '\n# BEGIN Codex-managed OP_SERVICE_ACCOUNT
अक्सर पूछे जाने वाले सवाल

क्या यह तुरंत SSH सेटिंग बदल देती है?

नहीं। स्किल कहती है कि SSH सर्वर फ़ाइल बदलने से पहले संदिग्ध कॉन्फ़िग लाइनें रिपोर्ट करें।

स्थानीय विफलता का क्या मतलब है?

कि समस्या सर्वर सेटअप में है, जैसे SSH सेवा या उसकी कॉन्फ़िगरेशन में।

टेस्ट कमांड कैसे चलने चाहिए?

नॉन-इंटरैक्टिव रूप से, ताकि वे प्रॉम्प्ट पर अटकें नहीं।

जानकारी

लेखक का मूल विवरण

SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions.

repo: steipete/agent-scripts

लोकप्रियता

GitHub स्टार
7.4k
रैंकिंग में स्थान
#13247
लाइसेंस
MIT
अपडेट की गई
30/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

beeper

7.4k

आपके एजेंट को आपकी लोकल Beeper चैट हिस्ट्री में संदेश खोजने और यह पता करने में मदद करती है कि कोई अस्पष्ट संकेत किस चैट या संपर्क का है।

डेटाडेटाबेस

cloudflare-registrar

7.4k

आपके एजेंट को Cloudflare Registrar पर डोमेन की कीमत और उपलब्धता जाँचने, और पुष्टि के बाद डोमेन रजिस्टर या सूचीबद्ध करने में मदद करती है।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

codexbar

7.4k

आपके एजेंट को Codex, Claude और Kimi जैसी AI सेवाओं पर आपका कितना उपयोग बचा है, यह जाँचने में मदद करती है, जिसमें सीमा, क्रेडिट और रीसेट का समय शामिल है।

AI और एजेंटएजेंट

create-cli

7.4k

आपके एजेंट को कमांड लाइन टूल के कमांड, फ़्लैग, हेल्प टेक्स्ट, आउटपुट और एरर इस तरह डिज़ाइन करने में मदद करती है कि वह लोगों और स्क्रिप्ट दोनों के लिए काम करे।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills