Auto login with SFTP

Hi All,

How do you get around SFTP not having the 'cat' command to set up scripts to run cron jobs for passwords?
I am use to the FTP allowing that, but we are converting to SFTP and need to be able to still run the same scripts in off hrs. Is there a way to still cat the password at the prompt in the sftp> username
Password:
without doing it manually??

Are you talking abt hard-coding the password in your script?

No, I has it save in a file and had been using 'cat' to put on the password prompt line.
As : cat /home/sysadmin/.pp where .pp is a hidden file only the owner can see.
Since 'cat' is not part of SFTP I am looking for another way to do this in sftp.

Instead of using sftp, scp will be a better and secure method:p

I do not have a option on this as this is a Dept. Of Labor server I maintain. They put the operating system and programs on it for me to use. Unfortunately I have no other option then SFTP as they are killing FTP.

Some of the thoughts in my mind....

I think you can go ahead with ssh connection if the terminal login option available

and use some variables to pass the values

and kill ssh section after use if required... :slight_smile:

GIC,

How do you go about that?

insted of ftp/sftp you are loggfing into the box using keys

and then you can use what ever command you need.

ssh user@host

i hope u r getting me.. na..

I have never used keys to get into the box that way before. Most of everything we have on our server as far as keys is encrypted and I have no access to that. In other words, I can not become root on this server!

When you sftp to the target machine, you have to provide a username and password correct?

Instead of using sftp, try the following using the same username and password that you use for sftp:

ssh username@targetmachine
It will prompt you for a password, enter the password for that user.

If you can login with ssh, then read up a ssh-keys tutorial like:
Suso Technology Services -- Web Hosting,Web Design,E-mail Hosting, XEN hosting, Dedicated Servers, Colocation, Web Design and Web Development in Bloomington, Indiana

Then use scp to transfer the files accross without needing to supply username or password.

apra143,
It allowed me to login but gave a message of :
no xauth data; using fake authentician data for x11 forwarding.
Could not chdir to home directory : No such file or directory
FSUM7358 no HOME directory
This is a test server they are setting up, so its possible everything is not all set yet. I will check with the IT team. This at least gives another direction to explore.

try if you can change this to sftp

#!/bin/ksh
HOST='ftp.users.abcd.com'
USER='yourid'
PASSWD='yourpass'
FILE='file.txt'

ftp $HOST <<END_SCRIPT
user $USER
$PASSWD
put $FILE
quit
END_SCRIPT
exit 0

And Im not sure if you did a reference down here:

incredible,
Tried using the script you showed me only using sftp instead of ftp, as ftp will be completely going away on the server shortly. It prompts for password and then continues to hang like before. So either the receiving is not set properly of I still have something missing. This is a direct connect behind a secure firewall. I will not be leaving and going to an outside lan, but rather stay within our own secure lan. It can not be seen from out side our site.

#!/bin/ksh
HOST='connecting ip'
USER='userid'
PSSWD='password'

sftp $HOST <<END_SCRIPT
user $USER
$PSSWD
quit
END_SCRIPT
exit 0

i think your firwall port 22 is not opened external to lan.

other wise some NATing probs if ftp working NATing working fine..

some suggections

1) after firing sftp try netstat -an |grep 22 for checking connections on other window

2) try sftp -v username@ip option it will gave more logging to analzie the issue.