orion_tvv
orion_tvv

Reputation: 1881

Fabric/python. Run remote command with local sshkey

I am trying to automate a deployment process. My project is in mercurial repo. I have a local machine LOCAL with user LOCAL_USERand ssh-key (~/.ssh/KEY_LOCAL). Also I have remote server REMOTE with user REMOTE_USER and ssh-key ('~/.ssh/KEY_REMOTE').

env.hosts = ['REMOTE']
env.user = 'REMOTE_USER'

def pull():
    with cd(repo_path):
        run('hg pull -u')

I can connect to REMOTE server, but hg trying to use REMOTE_USER.

Is it possible to use hg on REMOTE SERVER with LOCAL_USER + SSH_KEY_LOCAL?

Upvotes: 0

Views: 170

Answers (1)

James Robinson
James Robinson

Reputation: 822

Mercurial on the REMOTE server does not have access to the ssh key on LOCAL. While there may be some way to copy it on the fly, or do some weird mounting, I would advise against that.

What you should do is create a different private key on the REMOTE server, and then copy it's public key to your Mercurial server for the user LOCAL_USER. This way you'll end up with one user with two different public keys on the Mercurial server, with each private key on a different box.

If you trust the REMOTE server %100 you could just copy your current private key over, but that's generally not a good idea.

Upvotes: 1

Related Questions