Suggested SSH/SFTP/SCP options when creating a script:
- Do not store the remote host's SSH public keyfile for later
"-o UserKnownHostsFile=/dev/null"
- Do not check for the remote host's SSH public keyfile in known_hosts
"-o StrictHostKeychecking=no"
- Do not check localhost's SSH public keyfile in known_hosts
"-o NoHostAuthenticationForLocalhost=yes"
- Do not attempt authenticate using a password or prompt for password
"-o PasswordAuthentication=no"
- Attempt authenticate using the specified SSH private key file (default file shown)
"-i $HOME/.ssh/id_rsa"
All options above included in a test command:
touch $HOME/test.txt; \The command above presumes a SSH private key exists and the corresponding public key has been appended to authorized_keys.
scp \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeychecking=no \
-o NoHostAuthenticationForLocalhost=yes \
-o PasswordAuthentication=no \
-i $HOME/.ssh/id_rsa \
$HOME/test.txt \
$USERNAME@localhost:test-`date +%Y%m%d-%H%M%S%N`.txt
Comments