file transfer from remote server to sftp using shell script - shell

I have a file in my remote server which needs to be transferred to sftp box.
I do have the password, port and username for sftp box.
Please share me a shell script programming to understand how this can be done.

you can go for passwordless authentication between remote server and sftp box via sharing the public key .
OR , you can use
scp filename sftpuser#sftphost:/$destination_Path

Related

SFTP file from one remote server to other remote server using shell script without expect package

I'm trying to automate the transfer of files from one remote server to other remoter server using shell script. I cannot install expect package. Could anyone help me out in doing this?
Thanks.
Setup a password less login between remote server so it won't ask for password in shell script and it will avoid passing password in shell script for security reason
Please refer the below link to setup password less ssh
http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
Then write a shell script to sftp the files
refer the SFTP command in the below link to do the needful
http://www.tecmint.com/sftp-command-examples/

Shell Script to access a remote machine using ssh with usr and pwd both

I am writing a shell script that can connect to another remote machine and query the DB , write the result in a file and copy the file back to main machine.
I am facing issue while connecting to DB.
I am not understanding how to connect to the remote machine.
I am using ssh root#DB_IP the then ORACLE query. But its always asking a password.
How to provide both username and password while doing a ssh to the remote machine?
You can do this by two ways:-
By adding your id.rsa.pub in your remote machine (~/.ssh/authorized_keys)
sshpass -p password ssh root#ip "sh run.sh "

reading remote images in ssh server with matlab

Is it possible to read an image in a remote server with ssh in a matlab code?
I mean, I want to do this, but Matlab is not allowing:
image_file=strcat('sftp://user#ssh_server/user/images/image_name.tif');
imread(image_file);
I can login in this ssh server without password.
Assuming that you are on linux/unix, you can use scp from matlab to fetch the file, e.g.
!scp username#localhost:/tmp/source/test.png /tmp/
% please note ! at the beginning.
This will prompt you for password offcourse. Thus, if you want, you can setup public-key authentication for passwordless scp command.

Shell Script program to download files from linux remote server

I am very new in shell scripting , i want to download some files from linux remote server ,so how can i proceed for that.That remote server is ssh based .
first of all, ftp service is better choice to get files from remote server.
If only sshd service is available, then you may use ssh based command sftp or scp.
However, using sftp or scp commands will invoke an interactive password prompt, which is a problem in shell script --> You have to ask for help to expect command. see Automate scp file transfer using a shell script .
Besides expect, you may also set up trust relationship between two servers, then you may use scp without password. See http://www.linuxproblem.org/art_9.html

bash script to sftp files with a password from remote directories to local folders

How to write a bash script using sftp command to download files?
I can use the following command to login to the remote machine, however I need to type in the password manually.
bash-3.2$ sftp -o "Port 22022" mike#s-edm-ssh.local.files.stack.com
mike#s-edm-ssh.local.files.stack.com's password:
Connected to s-edm-ssh.local.files.stack.com.
sftp>
How to do the sftp without the password prompt?
If I like to download aaa.txt file at /remote/mike/files to my local directory /local/mike/downloaded, how to build a script to do all of these work?
Since sftp runs over SSH, you can place your public key on the remote server.
If for some reason you can't place your key on the server, then you can write an Expect script to send your password when the prompt appears. See this example.

Resources