Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there an option to put the password on the line as well with sftp?

linux~ $ sftp USERNAME@FTP.WEBSITE.COM:/DIRECTORY_TO_GO_TO/

Like this

linux~ $ sftp USERNAME@FTP.WEBSITE.COM:/DIRECTORY_TO_GO_TO/ -p PASSWORD?
share|improve this question
add comment

6 Answers

up vote 6 down vote accepted

Generally including a password in a command line is considered a security risk because it will show up to anyone else who can run ps/top, and it may be saved in your shell's history.

It would be a much better idea to setup key-based authentication if you are able.

Also, I don't believe it is going to be possible with sftp. It is meant to be used for secure transfers. If you really had to do something like this and you have no other choice then you probably need to be looking at automating with expect.

share|improve this answer
    
Interesting point! –  Daniel Oct 13 '09 at 19:32
add comment

As others have mentioned, a command-line password should be the last resort.

However, if nothing else is possible; one can go for ssh pass

sshpass -p <password> sftp user@host
share|improve this answer
1  
This should be massively upvoted. It is really useful to have sshpass. Some providers don't allow you to create a .ssh folder and scp is also disallowed. –  NetSquirrel Jul 5 '13 at 1:38
add comment

Don't do that - setup SSH public key authentication for automatic login.

share|improve this answer
    
Can sftp do this the same is scp? –  Daniel Oct 13 '09 at 19:32
    
@Daniel, both sftp and scp are built on SSH which allows for key-based authentication. –  Zoredache Oct 13 '09 at 23:19
add comment

As the other answers have stated, use public key authentication. There is a great, although a little dated, IBM developerWorks series that should explain everything you want to know about it, as well as some useful supplemental tools such as keychain.

share|improve this answer
add comment

Just use perl or ruby or python to script what you are trying to do. in case of ruby it's just (taken from the net-sftp API docs):

require 'net/sftp'

Net::SFTP.start('host', 'username', :password => 'password') do |sftp|

# upload a file or directory to the remote host

sftp.upload!("/path/to/local", "/path/to/remote")

end

for more info http://net-ssh.rubyforge.org/sftp/v2/api/index.html

share|improve this answer
    
paramiko is pure python (no extra libs) and works really well –  qwertzguy Oct 31 '12 at 10:52
add comment

I suspect that there are as many answers as there are FTP clients. An SFTP server should not accept authentication information until encryption is established, so that the user and password are protected.

I believe the FileZilla client will allow for command line passing of the user and password .. see the documentation here. Given the reputation of the FileZilla project, I would expect it to operate securely.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.