Created
January 24, 2017 18:37
-
-
Save angrychimp/403224392a7208198e276b28d283c571 to your computer and use it in GitHub Desktop.
Setting up SSH keys for key-auth with ProFTPd (w/ SFTP module)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.