Posts

Showing posts from August 7, 2016
SFTP auto login without keys / without password

sftp command doesn't have option to specify password for auto login.

Recently faced this issue while writing a script on SUSE Linux for transferring system performance report to a central location, which is also a SuSE system.

We can accomplish this with "lftp" or "expect" command, but SLES doesn't install those binaries default.

I've to live with what I got, so let’s try how we can accomplish this with sftp command.


The idea is

1.Set "SSH_ASKPASS" environment variable and force "sftp" command to read password from there.

2."sftp" will always ask password if its executing from a terminal, so we need to daemonize sftp command with "setsid" command


Below code snippets will give some idea how we get it to the solution

pathnames.h

/* Default path to ASKPASS program */

#define _PATH_SSH_ASKPASS_DEFAULT   "/usr/X11R6/bin/ssh-askpass"

ssh.h

/*
 * Environment vari…