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

  • Home
  • SEARCH
  • 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 8327843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:14:58+00:00 2026-06-09T01:14:58+00:00

I ssh into a shared host (WebFaction) and then use ssh-agent to establish a

  • 0

I ssh into a shared host (WebFaction) and then use ssh-agent to establish a connection to a mercurial repository (BitBucket). I call the agent like so:

eval `ssh-agent`

This then spews out the pid of the agent and sets its relevant environment variables. I then use ssh-add as follows to add my identity (after typing my passphrase):

ssh-add /path/to/a/key

My ssh connection eventually times out and I’m disconnected from the server. When I log back in, I can no longer connect to the Hg server and so I do this:

ps aux | grep 1234.*ssh-agent`
kill -SIGHUP 43210

And then repeat the two commands at the top of the post (ie. invoke the agent using eval and call ssh-add).

I’m sure that there’s a well established idiom for avoiding this process and maintaining a “reference” to the agent that was spawned initially. I’ve tried redirecting I/O of the first command to a file (in the hope of sourcing it in my .bashrc), but I only get the agent’s pid.

How can I avoid having to go through this process each time I ssh into the host?

My *NIX skills are weak, so constructive criticism on any aspect of the post is welcome, not just my use of ssh-agent.

  • 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-09T01:15:00+00:00Added an answer on June 9, 2026 at 1:15 am

    Short answer:

    With ssh-agent running locally and identities added, ssh -A user@host.webfaction.com provides the secure shell on the remote host with the local agent’s identities.

    Long answer:

    As Charles suggested, agent forwarding is the solution.

    At first, I thought that I could just issue an ssh user@host.webfaction.com and then, from within the secure session on the remote host, connect to the BitBucket repository using hg+ssh. But that failed, and so I investigated the ForwardAgent and AgentForwardingEnabled flags.

    Thinking that I’d have to settle for a workaround in .bashrc that involved keeping my private key on the remote host, I went looking for a shell-script solution but was spared from this kludge by this answer in SuperUser, which is perfect and works without any client configuration (I’m not sure how the sshd server is configured on WebFaction).

    Aside: in my question, I posted the following:

    ps aux | grep 1234.*ssh-agent`
    kill -SIGHUP 43210 
    

    but this is actually inefficient and requires the user to know his/her uid (available via /etc/passwd). pgrep is much easier:

    pgrep -u username process-name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ssh in Terminal to ssh into a Linux host where I'm running
Is there a way I can use NSTask to ssh into another computer (in
I'd like a command that ssh'es into a machine, runs a command (cd or
I am trying to use pexpect to ssh into a computer but I do
So I have a script that ssh into another computer. Since I use it
I would like to save the keystrokes I make to ssh into a server
I'm attempting to write a simple one-line script to ssh into a remote host,
When I SSH into an Amazon instance without an elastic IP I use the
When I ssh into a remote production server I would like the colour scheme
I'm currently trying to ssh into a remote machine and run a script, then

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.