From b32f42984994a397441a1c48f1a002e906624c51 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 21 Sep 2007 20:17:09 +0000 Subject: [PATCH] Added a no_tty param to remote URIs to stop SSH prompting for password --- ChangeLog | 6 ++++++ docs/libvir.html | 14 ++++++++++++++ docs/remote.html | 10 ++++++++++ src/remote_internal.c | 17 +++++++++++++++-- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1be07f2234..2763f79dc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Sep 21 16:22:00 EST 2007 Daniel P. Berrange + + * src/remote_internal.c: Add a no_tty flag to stop SSH prompting + for passwords on console + * docs/libvir.html, docs/remote.html: Document no_tty flag + Fri Sep 21 15:06:00 EST 2007 Daniel P. Berrange * acinclude.m4: Check all compiler flags link successfully diff --git a/docs/libvir.html b/docs/libvir.html index e5382bb2cc..9e0276c886 100644 --- a/docs/libvir.html +++ b/docs/libvir.html @@ -1762,6 +1762,20 @@ Note that parameter values must be Example: no_verify=1 + + no_tty + ssh + + If set to a non-zero value, this stops ssh from asking for + a password if it cannot log in to the remote machine automatically + (eg. using ssh-agent etc.). Use this when you don't have access + to a terminal - for example in graphical programs which use libvirt. + + + + Example: no_tty=1 + +

Generating TLS certificates

diff --git a/docs/remote.html b/docs/remote.html index 976fd5682f..7598a26882 100644 --- a/docs/remote.html +++ b/docs/remote.html @@ -195,6 +195,16 @@ Note that parameter values must be Example: no_verify=1 + no_tty + ssh + + If set to a non-zero value, this stops ssh from asking for + a password if it cannot log in to the remote machine automatically + (eg. using ssh-agent etc.). Use this when you don't have access + to a terminal - for example in graphical programs which use libvirt. + + + Example: no_tty=1

Generating TLS certificates

Public Key Infrastructure set up

If you are unsure how to create TLS certificates, skip to the next section. diff --git a/src/remote_internal.c b/src/remote_internal.c index 6eb896ffe5..d567374d4b 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -291,7 +291,7 @@ doRemoteOpen (virConnectPtr conn, struct private_data *priv, const char *uri_str */ char *name = 0, *command = 0, *sockname = 0, *netcat = 0, *username = 0; char *server = 0, *port = 0; - int no_verify = 0; + int no_verify = 0, no_tty = 0; char **cmd_argv = 0; /* Return code from this function, and the private data. */ @@ -356,6 +356,9 @@ doRemoteOpen (virConnectPtr conn, struct private_data *priv, const char *uri_str } else if (strcasecmp (var->name, "no_verify") == 0) { no_verify = atoi (var->value); var->ignore = 1; + } else if (strcasecmp (var->name, "no_tty") == 0) { + no_tty = atoi (var->value); + var->ignore = 1; } #if DEBUG else @@ -554,7 +557,10 @@ doRemoteOpen (virConnectPtr conn, struct private_data *priv, const char *uri_str } case trans_ssh: { - int j, nr_args = username ? 10 : 8; + int j, nr_args = 8; + + if (username) nr_args += 2; /* For -l username */ + if (no_tty) nr_args += 5; /* For -T -o BatchMode=yes -e none */ command = command ? : strdup ("ssh"); @@ -569,6 +575,13 @@ doRemoteOpen (virConnectPtr conn, struct private_data *priv, const char *uri_str cmd_argv[j++] = strdup ("-l"); cmd_argv[j++] = strdup (username); } + if (no_tty) { + cmd_argv[j++] = strdup ("-T"); + cmd_argv[j++] = strdup ("-o"); + cmd_argv[j++] = strdup ("BatchMode=yes"); + cmd_argv[j++] = strdup ("-e"); + cmd_argv[j++] = strdup ("none"); + } cmd_argv[j++] = strdup (server); cmd_argv[j++] = strdup (netcat ? netcat : "nc"); cmd_argv[j++] = strdup ("-U");