Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:13:08+00:00 2026-06-05T06:13:08+00:00

Can I do ssh-add against the identifyFile that stay forever, currently it prevail only

  • 0

Can I do ssh-add against the identifyFile that stay forever, currently it prevail only for the current active ssh session (i.e identityFile added using ssh-add get lost when a new ssh session is made with the server can be found by running ssh-add -L )

The problem is that our amazon server has various projects with repo resting in github.

Now each one of the repo has access right based on the users
say user A has access right only for project A and B has an access right on project B only

With that access right set(in github) now each user can perform git operation(like git fetch, git push etc) only to there respective project (which is what we want)

Now all I want is when a user perform a git operation on there respective project I want ssh-agent to take all ssh-keys in accounts and look for the one that match to that specific users

Note

that each ssh-key has a phrases(a unique secret know to each user there own) associated with it, prompted to enter when perform git function.

to achieve this we do

ssh-add /root/.ssh/A

or

ssh-add /root/.ssh/B

But as mention earlier this only stay for the active ssh-session ,exit or make a new ssh session with the server the ssh-add info is lost. can be found by running ssh-add -L

I have also tried defining IdentityFile in .ssh/config like this describe in this question

something like this

Host github.com
        Hostname github.com
        User git
        IdentityFile /root/.ssh/A

Host github.com
        Hostname github.com
        User git
        IdentityFile /root/.ssh/B

This only work for one user (sometime it work for ‘A’ and sometime it doesnt ,same is with ‘B’ too)

Can this segregation be achieved or am I sounding a bit over ambitious

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:13:10+00:00Added an answer on June 5, 2026 at 6:13 am

    You’re very close with your edit of the IdentityFile. However, you need to have unique hostnames listed in the IdentityFile. Because you used github.com as the hostname both times, when you try to connect to github.com, it has no idea which one to use.

    We have a similar setup. We have 5 users, all of whom log in to a single account. However, Github needs to see them each using their own ssh-key, so we have 5 keys. The trick to get around this is to make your file look like this

    Host UserA_github
            Hostname github.com
            User git
            IdentityFile /root/.ssh/A
    
    Host UserB_github
            Hostname github.com
            User git
            IdentityFile /root/.ssh/B
    

    Whenever UserB wants to do something git related, (e.g. clone one of their repositories) they will run…

    git clone UserB_github:UserB/MyRepo
    

    or something similar. This will behave as if they had entered…

    git clone github.com:UserB/MyRepo 
    

    except that it will use the appropriate IdentityFile/private key.

    I understand that my solution doesn’t use a persistent ssh-add but I think this will give you the same performance that you want. Unfortunately, your users will need to enter their passphrase each time they perform a transaction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been searching for a library that can access multiple ssh connections at once,
I know it's insecure. My school has a system that you can ssh into,
One of my developers has sent his SSH keys so I can add to
I have a public/private key pair set up so I can ssh to a
I frequently need to ssh into a server, but I can't ssh into it
How can you make SSH read the password from stdin, which it doesn't do
Can Maven copy local file to a remote server using SSH? I want to
I can't login to github with generated ssh-keys. I've followed this manual: http://help.github.com/linux-key-setup but
Is there a way I can use NSTask to ssh into another computer (in
My host allows limited access to SSH and Linux commands. However, I can't use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.