LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-21-2013, 12:48 AM   #1
niteen
Member
 
Registered: Mar 2013
Location: India
Distribution: Fedora
Posts: 66

Rep: Reputation: Disabled
script to sftp-auto-login and put a file


Dear all,
i want to make a directory and put a file into a remote machine via "sftp".
i have been through
Quote:
sshpass : likewise
sshpass -p 't@uyM59bQ' ssh username@server.example.com

and lftp also
wanted to ask whether there is any direct,without installing any other library into the system.
 
Old 11-21-2013, 01:12 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

you should be using public key authentication instead of sshpass. From the sshpass sourceforge page:
Code:
Description
Sshpass is a tool for non-interactivly performing password authentication
with SSH's so called "interactive keyboard password authentication". Most
user should use SSH's more secure public key authentiaction instead.
A web search with the keywords "ssh-keygen public key authentication" should provide plenty of good tutorials for this.

You should also probably scp or rsync with ssh instead of sftp. We can provide a more specific answer if you can ask a more specific question.

Quote:
wanted to ask whether there is any direct,without installing any other library into the system.
The remote system will need sshd installed running.

Evo2.
 
Old 11-21-2013, 03:01 AM   #3
niteen
Member
 
Registered: Mar 2013
Location: India
Distribution: Fedora
Posts: 66

Original Poster
Rep: Reputation: Disabled
Actually i am about to write a sftp-script
which will get/put files..
please put your important suggestions.
thanks in advance
 
Old 11-21-2013, 07:29 AM   #4
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
I recommend the simple syntax of scp instead of sftp, and using keychain.

Keychain (installed from my distro's repository) saves my passphrase in memory. I'm promoted for the passphrase the first time I login after a boot and it remembers it (even across logout/login) until I reboot or kill the process.

That let's me do things like this, on the command line, in a script or even in a crontab script, without being prompted for anything. Assuming I have an account on example.com and have appended my public key to the ~/.ssh/autorized_keys file on it.
Code:
ssh example.com mkdir examples
scp ~/text/onefile.txt ~/text/other.txt example.com:examples
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sh script to auto root login MCLASS Programming 2 04-27-2012 09:51 AM
SFTP auto login works one way only? jchambers Linux - Newbie 6 01-03-2009 01:29 PM
How to achieve auto Login to different server through SFTP protocol Dozzy Linux - Server 9 12-25-2008 10:50 PM
I wondering how to put the password in bash to auto login to others cpu Eatm3Pro Linux - General 2 08-18-2008 04:55 AM
ssh auto login script zerocool22 Linux - Server 4 05-13-2008 09:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration