Tuesday, June 30, 2015

FTP or SFTP without password in Linux

I want to make shell script to download the file automatically from the linux server. so i want to know, how to pass the username and password parameters in sftp command inside the shell script ?

FTP/SFTP without password

1. If you use sftp:
ssh-keygen
<no passphrase>
ssh-copy-id your_login@remote.host
Now you can log in without password and use simple command in your script: sftp your_login@remote.host

2. If you use ftp:
touch ~/.netrc
echo "machine <remote_host> login <your_login> password <your_password>" > ~/.netrc
chmod 600 ~/.netrc
Now you can login in without password - ftp remote.host

1 comment: