< All Topics

How to Login to SFTP with One Line on Linux

Using SFTP is fairly simple with Linux. However, the normal method may cause issues with automation. Using Linux you can connect to your SFTP server with just one line.

Normal Method

The normal way to login to SFTP on Linux is: Sftp username@host
For example: “Sftp test@ftp.hostedftp.com”
Once you enter this command, it will then ask you for the password. This can be an issue if you are trying to automate a process.

Using One Line

If you are on Linux and you need to login to your SFTP site with just one line, you need to install a library called sshpass.

To install sshpass, enter the following command:
sudo apt-get install sshpass

once you install sshpass, enter the following command to login to your sftp with one line:
sshpass -p “password” sftp username@host

For example if your username is test and password is test001, the command will look like this:
Sshpass -p test001 sftp test@ftp.hostedftp.com

More Resources

For more information on connecting to SFTP with linux read more here. Learn more about using PKI keys with linux here. Or to learn how to import PuttyGen keys to linux view this article.

Table of Contents