Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


Like this

share|improve this question
up vote 10 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

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
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

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

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

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")


for more info

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

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

Your Answer


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.