Super User is a question and answer site for computer enthusiasts and power users. 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

I cant scp, the other server only takes sftp connections.

Currently, I am trying to do

sftp> put -r ~/

-i keyname does not work, just resolves with illegal option -- i.

share|improve this question

migrated from Oct 4 '12 at 20:50

This question came from our site for professional and enthusiast programmers.

up vote 15 down vote accepted


sftp -o "IdentityFile=keyname"

You can use -o to pass any option that's valid in ~/.ssh/config.

share|improve this answer
Nailed it. thanks! how do i keep it there normally? – Jay Oct 5 '12 at 0:00
I don't know what you mean by "keep it there normally". If you mean that you want the IdentityFile option to always automatically be given, check out UtahJarhead's answer about putting it in ~/.ssh/config – Celada Oct 5 '12 at 1:38

If you are looking to setup sftp on ec2, this article might help

share|improve this answer
Sorry, it really didnt. – Jay Oct 5 '12 at 0:01

Copy your PUBLIC key to the server using traditional means.

On server:

  • Create .ssh if it doesn't exist:
[[ ! -d "${HOME}/.ssh" ]] && mkdir -p "${HOME}/.ssh"
  • Implement the public key:
cat /path/to/ >> "${HOME}/.ssh/authorized_keys"
  • Set appropriate permissions. OpenSSH is VERY ANAL about the permissions of the files in question:
chmod go-rwx "${HOME}" "${HOME}/.ssh/authorized_keys"

After that, you should be able to log in from the client using the PRIVATE key. To automate a transfer, you want to use a batch file, which is just a text file containing a list of commands to execute.

echo "put /safe/path/" >> /tmp/batchfile.txt
sftp -b /tmp/batchfile.txt -oIdentifyFile=/path/to/private_key user@host

Alternatively, feel free to create a ~/.ssh/config file in ssh_config format so you can just type this in the future:

sftp -b /tmp/batchfile.txt host

Sample contents of ~/.ssh/config

Host the_hostname
    User user_name
    IdentityFile /path/to/private_key
share|improve this answer
Ill try this on the next batch, the solution above did the trick though. – Jay Oct 5 '12 at 0:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .