When making transfers via the command line with
ascp, there are a number of ways you can provide credentials for the transfer user of the server you’re connecting to. You can provide the transfer user’s password by typing it in when prompted, you can set the password as an environment variable, or you can set an SSH key for the user. When automating transfers such as with a script, the recommended method is using an SSH key as it is most secure. Instructions for all of these methods are below.
Manually entering the transfer user password
By default, you need to type in the transfer user’s password each time you make a transfer.
For example, to transfer file important-doc.txt to the document root of the user janedoe at example.com, you might use the following command and see the resulting password prompt:
ascp /path/to/important-doc.txt firstname.lastname@example.org:/
After the password is authenticated, the transfer completes.
Setting an environment variable
You can also save the transfer user’s password in an environment variable if you prefer not to type it out each time, or if you are making transfers through a script.
The environment variable to set is
ASPERA_SCP_PASS. You can set this environment variable using the following command, where transfer-user-pw is the password of the transfer user:
Linux and Mac OS X
Setting an SSH key
If you would prefer not to have to deal with the transfer user password at all, you can also set an SSH key for the user. This would only require you to include the location of your private key file in the
ascp command in order to connect to the transfer user. Use the following instructions for setting an SSH key.
1. Create an
.ssh folder in your home directory. You can do this with the following command:
Mac OS X
2. Generate an SSH key-pair.
Run the following command in your
ssh-keygen -t rsa
Press ENTER to use the default name
id_rsa. You can choose to enter a passphrase, but since you are likely using SSH keys to avoid providing passwords, you can press ENTER twice to leave this blank.
3. Provide the public key file (
id_rsa.pub, for example) to the administrator of the server you want to connect to. They will themselves create a
.ssh folder in the transfer user’s home directory and add the public key to the end of the
4. You are now ready to make transfers with your SSH key. Your
ascp command will need to include the
-i flag followed by the location of the private key file you generated:
ascp -i path/to/home_dir/.ssh/id_rsa yourfile.txt email@example.com:/