Skip to content

Instantly share code, notes, and snippets.

@azz
Created April 10, 2017 04:17
Show Gist options
  • Save azz/ce63c9b34f3ce92511f726b369e7476f to your computer and use it in GitHub Desktop.
Save azz/ce63c9b34f3ce92511f726b369e7476f to your computer and use it in GitHub Desktop.
How to use node-ssh (or ssh2) with TeamCity's ssh-agent

This is actually really straight forward, just use the SSH_AUTH_SOCK environment variable:

const socket = process.env.SSH_AUTH_SOCK
const ssh = new (require('node-ssh'))

ssh.connect({
  username: 'username',
  host: 'example.com',
  agent: socket
}).then(() => {
  // success
}, console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment