Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- USERNAME="your username here"
- SFTPHOST="your sftp host"
- SFTPPORT=22 # or other port, if non-standard
- # Create SSH key-pair for SFTP access
- # (creates pair with no passphrase)
- ssh-keygen -b 2048 -t rsa -C "$SFTPHOST" -N "" -f ~/.ssh/id_rsa.sftp
- # Create authorized_keys file for upload
- ssh-keygen -e -f ~/.ssh/id_rsa.sftp.pub -m RFC4716 > ~/.ssh/authorized_keys.sftp
- chmod 600 ~/.ssh/authorized_keys.sftp
- # Upload authorized_keys file to sftp
- # (this will prompt for a password)
- scp -P $SFTPPORT ~/.ssh/authorized_keys.sftp $USERNAME@$SFTPHOST:.ssh/authorized_keys
- # Verify key-auth is working
- # (should log in without password prompt)
- sftp -o IdentityFile=~/.ssh/id_rsa.sftp -o Port=$SFTPPORT $USERNAME@$SFTPHOST
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement