Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

702
Vistas
How can I pass a password to git in a ruby script

I'm working on a small ruby script that will checkout and sync a branch on two different servers. I'm trying to figure out how to pass a password to git when pulling. Right now I have

Net::SSH.start(host, user, password: password) do |ssh|
  # other code....
  result = ssh.exec!("git pull")
  # results in Enter passphrase for key '/root/.ssh/id_rsa'
end

After running the git command it get a prompt for the key passphrase.

Is it possible to pass that in with a git command? Or is there another way to do that within ruby?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The net-ssh documetation does mention the method Net::SSH.start() accepts a passphrase argument:

passphrase
the passphrase to use when loading a private key (default is nil, for no passphrase)

So if you can get the passphrase (from a file or environment variable) in your program, you can add that argument to the Net::SSH.start() method.

Once you are connected, however, it is best to:

  • use a passphrase-less key for Git SSH URL
  • or use an HTTPS URL instead, for git pull commands, since you can register once and for all the password (not passphrase) associated with that HTTPS URL in a credential storage.

Using a passphrase means adding to your SSH session:

  • running the ssh-agent
  • entering the passphrase through a script

That seems quite cumbersome.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda