Pages

Tuesday, December 14, 2010

Automating sftp with shell script

1. Create public key on local machine

ssh-keygen -t rsa

(just choose the default options. let the passphrase blank, or else you have to enter the passphrase everytime you login. this should generate /home/localuser/.ssh/id_rsa.pub)

2. Login to remote machine 
3. Create file /home/remoteuser/.ssh/authorized_keys (if .ssh folder doesn't exists then create it, and if authorized_keys file is exists then use it)
4. Copy the contents of id_rsa.pub on local machine to authorized_keys file on remote machine
    scp .ssh/id_rea.pub remotehost:.ssh/authorized_keys
5. Run ssh-add on local machine, then you can run: "sftp remoteuser@remotehost" without password

No comments:

Post a Comment