Copy file to server that support only SSH2


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Copy file to server that support only SSH2
# 1  
Old 08-10-2012
Copy file to server that support only SSH2

Dear community,
I have to copy a file from Red Hat to another server that supports only SSH2.

SFTP command from Red Hat works fine, but since I have to insert SFTP command into a script, is it possibile to PUT file using SFTP in "one" line code?
Or, anyway, without using external file?

This works, but instead to put, it GET the file FROM the server:
Code:
sftp user@10.99.1.12:/root/filetoput

# 2  
Old 08-10-2012
sftp and scp use the exact same protocol; if you can connect with sftp, you can connect with scp.

Code:
scp local-file username@host:/path/to/remote/file

# 3  
Old 08-10-2012
With scp I got this message:
Code:
# scp local-file user@10.99.1.12:/path/to/remote/file
scp1 compatibility mode is not supported.

This because, as far I know, SCP supports only SSH v1 and destination server accept only connection with SSH v2.

Instead with SFTP, I got:
Code:
sftp user@10.99.1.12
sftp> put test.sh
Uploading test.sh to /SYS$SYSDEVICE/USER/test.sh
test.sh                                                                                           100%  108     0.1KB/s   00:00

So, it's currently working, the only things is that SFTP works in interactive mode, so that's why I'm asking if there is a way to put the command in one line without using external file.
# 4  
Old 08-11-2012
Quote:
Originally Posted by Lord Spectre
This because, as far I know, SCP supports only SSH v1 and destination server accept only connection with SSH v2.
Three seconds of checking in man scp finds this:

Code:
     The options are as follows:

     -1      Forces scp to use protocol 1.

     -2      Forces scp to use protocol 2.

...so I don't think that's accurate at all.
# 5  
Old 08-11-2012
Quote:
Originally Posted by Corona688
Three seconds of checking in man scp finds this:
YEP! Already tried without success: Smilie
Code:
# scp -2 server1.log user@10.99.1.12:server1.log
         This is SERV11, Unauthorized Access Prohibited.
scp1 compatibility mode is not supported.

The server machine is OpenVMS OS. Last days I had found a solution with pscp (putty scp). But, if one of the server is unreachable (e.g. for maintenance), the PSCP hangs. That's no good since the script runs from crontab every 5 minutes!
With OpenSSH I can setup the TimeoutConnection to a few seconds, so if the server is down, the script continues with the copy to the other servers after a few seconds.

I cannot find any way to downgrade the timeout on PSCP as already do on OpenSSH.
# 6  
Old 08-11-2012
Code:
sftp -b - user@host <<< 'put file'

You can omit the "-b -" part, but then sftp will always exit with 0 even if it fails.

Last edited by binlib; 08-11-2012 at 10:43 AM..
This User Gave Thanks to binlib For This Post:
# 7  
Old 08-14-2012
Thank you binlib, this is a nice workaround, but, at this point, I prefer to use an external sftp command file rather than a WA. This for script stability! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to copy a file from one server to anther server and execute the binary

Hi , Is there any script to copy a files (weblogic bianary + silent.xml ) from one server (linux) to another servers and then execute the copy file. We want to copy a file on multiple servers and run the installation. Thanks (1 Reply)
Discussion started by: Nawrajesh
1 Replies

2. UNIX for Advanced & Expert Users

Secure Copy - File Transfer between 2 server

Using RCP command we can transfer file from one server to another server. While transferring we can rename the file also e.g. File name = FILE123.txt (lying on Source server = oldserver) Target Server Name = newyour Renamed File = FILE456.txt rcp FILE123.txt newyour:./FILE456.txt... (1 Reply)
Discussion started by: Pash
1 Replies

3. UNIX for Dummies Questions & Answers

SFTP connection to SSH2 UNIX server

Plz share how we can make a passwordless SSH connection from a SSH1 UNIX server to SSH2 UNIX server. (3 Replies)
Discussion started by: krishna87
3 Replies

4. UNIX for Dummies Questions & Answers

Copy the newest file from a different server to your home server.

Hi all, So I am on server 1, and I want to grab the newest file from a particular directory on server 2, and place this in a directory on server 1. I am trying to use: ls -tr | tail -1 This works, and gets me the newest file in a particular directory. Using svn `ls -tr | tail -1` etc I... (1 Reply)
Discussion started by: Lexx87
1 Replies

5. Shell Programming and Scripting

track one file and copy to another server

Hello Friends, I am new to scripting, please guide me in below problem: I want to track a file, if anyone make any changes to that file then script should copy it to another server. my whole purpose is to backup a critical file automatically when any change is done to that specific... (1 Reply)
Discussion started by: makkar4u
1 Replies

6. UNIX for Dummies Questions & Answers

Copy a windows CVS file to the unix server as a svs file

I so desperately need a script to copy a windows csv file to my unix server and i know these should be at dummies but i have no bits. it is life & no job situation help please. thanks (1 Reply)
Discussion started by: zhegal
1 Replies

7. Shell Programming and Scripting

Copy file from one server to multiple server

can some one help me to write a shell script that copy one file from one server to multiple server ex:suppose i wnt to copy file abc.txt which is in server 1 to server2,server3,server4....:confused: (6 Replies)
Discussion started by: alokjyotibal
6 Replies

8. Shell Programming and Scripting

Copy a file on remote server

I have ssh keys setup and running properly between two servers. I have a Korn shell script that is logging into the remote server and needs to backup the authorized_keys and/or authorized_keys2 files. The following syntax works perfectly ------------------------------------- ssh... (1 Reply)
Discussion started by: sunsysadm2003
1 Replies

9. Shell Programming and Scripting

Can't Delete File using ssh2

hi, i am getting error while executing the follwoing command. /usr/local/bin/ssh2 user@hostname find /test/DeleteFile -mtime +10 -exec rm {} \; error is : find: 0652-018 An expression term lacks a required parameter. it is deleting the files from the specified location. it is working... (2 Replies)
Discussion started by: Sunil Rajput
2 Replies

10. Programming

Command for copy a file from one server to another server

hi, which Command is used for copy a file from one server to another server, please provide the syntax and give one small example... Thanks in advance sarwan (2 Replies)
Discussion started by: sarwan
2 Replies
Login or Register to Ask a Question