sftp icon

SFTP Access

Version: latest

Logging in with Command Line in Unix Systems (Linux and MacOS)

If you want to access SFTP from a script or if you simply prefer command line over GUI, this is the option to go with.

Nowadays sftp command is available by default in most Unix systems. If the sftp command is not available in your system please install OpenSSH which includes an SFTP command line client.
  1. First download the private key file from the SFTP view.

  2. Then before using the login command, we first have to set correct permissions to the private key file. In-order to set the correct permission, navigate to the directory where the downloaded private key file is stored and run the below command. Remember to replace the <private_key_file> part with the actual private key file name when you execute the below command.

    sudo chmod 400 <private_key_file>

    Note that if you do not set correct permission to the private key file, you’ll get an error message similar fo following when you try to run the SFTP login command.

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for 'id_rsa_rajind' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for 'id_rsa_rajind' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "id_rsa_rajind": bad permissions
    rajind@sftp.as2gateway.com: Permission denied (publickey).
    Connection closed
  3. Now you can run the SFTP login command as follows. Please replace <private_key_file with the your private key file name with path and replace <user_name> with the SFTP username (the username which was used in the form when setting up SFTP) when executing the below command.

    Note that at the first time when you run the sftp login command, you will be prompted for the private key passphrase. Please provide the password which you used in the form when setting up SFTP as the passphrase.

    sftp -o Port=9193 -o IdentityFile=<private_key_file> <user_name>@sftp.as2gateway.com
In this topic
In this topic