Sponsored Content
Full Discussion: Secure copy help
Top Forums UNIX for Dummies Questions & Answers Secure copy help Post 302522858 by Blytsplyk on Monday 16th of May 2011 10:41:48 PM
Old 05-16-2011
Technically, scp does create directories if you specify the -r option but that means you need to copy the entire directory and not just a single file:

-r Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal.

Example using scp locally:

/home/blytsplyk: ls -lr dir1
total 4
drwxr-xr-x 2 blytsplyk users 4096 May 16 19:30 tmp
-rw-r--r-- 1 blytsplyk users 0 May 16 19:27 file1
/home/blytsplyk: ls -lr dir2
ls: cannot access dir2: No such file or directory
/home/blytsplyk: scp -r dir1/* dir2
dir2: No such file or directory
/home/blytsplyk: mkdir dir2
/home/blytsplyk: scp -r dir1/* dir2
/home/blytsplyk: ls -lr dir2
total 4
drwxr-xr-x 2 blytsplyk users 4096 May 16 19:31 tmp
-rw-r--r-- 1 blytsplyk users 0 May 16 19:31 file1

As for the original question, while your home directory may not have the same name on the remote system as it does on the local system, by default, if you do not specify a directory name, scp will use the home directory on the remote system when copying the file. Therefore, if you simply want to copy a file from your home directory on one system to your home directory on another system, you can just do this:

scp file user@server:

There is no need to specify the trailing ~/. In fact, if your account name is the same, there is no need to specify user@ either. And, finally, if you set up your ssh keys, there would be no need to enter your password. I don't personally use sftp since I don't have a need to automate transfers between Windows and Unix machines but I believe newer version of sftp take advantage of ssh so you would still need to set up ssh keys if you want to avoid manual password entry.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

looking for a secure copy program (scp)

Hi could someone tell me where to find a secure copy prog. for unix and windows thnx a lot helios (4 Replies)
Discussion started by: helios
4 Replies

2. Shell Programming and Scripting

how to use SCP (secure copy) in UNIX

i have to transfer a file from one server to another. say, my script is running on server 'A' and one file has to be transferred from server 'A' to server 'B' using SCP. i am using it as: sourceserverA> scp -P <port> userid@serverBhostname:/put/this/here <sourcefile path> but it is giving... (1 Reply)
Discussion started by: dharmesht
1 Replies

3. UNIX for Dummies Questions & Answers

SCP - Secure copy with Certificates exchange.

Will an scp command always copy the files in an encrypted mode? After trying this, I have got message Host Key not found in the database. & Unable to write host key in my user directory. Please anyone has an idea, how we can have secure copy with certificates exchanged successfully? (0 Replies)
Discussion started by: videsh77
0 Replies

4. Solaris

Secure FTP Problem using Sun SSH on Client system F-Secure on Server system

I am using shell script to do secure ftp. I have done key file setup to do password less authentication. Following are the FTP Details: FTP Client has Sun SSH. FTP Server has F-Secure. I am using SCP Command to do secure copy files. When I am doing this, I am getting the foll error scp:... (2 Replies)
Discussion started by: ftpguy
2 Replies

5. UNIX for Dummies Questions & Answers

What is in-core copy and disk-copy of i-node table?

I have found a question from the exercises of my study mat. The question is "Why are there a in-core copy and a disk-copy of i-node block and super block?" If any one know the proper answer then please send me..... (1 Reply)
Discussion started by: dearanik
1 Replies

6. Shell Programming and Scripting

Help with Secure Copy (SCP) command

Hi, I am in the process of converting ftp transfres to SCP in my scripts. Have some doubts with SCP command 1) currently script puts a list of ftp commands in afile and paasses the file to ftp as input echo "user abc pwd" >inputfile echo "ls *" >> inputfile echo "quit" >> inputfile... (5 Replies)
Discussion started by: justchill
5 Replies

7. UNIX for Advanced & Expert Users

Secure Copy, scp

Is there a way we can avoid asking of password when we transfer file from one Unix server to another server using SCP command. Or Is is possible that the batch file in unix in which I am giving the SCP command takes the password and transfer the files automatically without me typing the... (1 Reply)
Discussion started by: Pash
1 Replies

8. 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

9. Shell Programming and Scripting

how to copy the directory but not copy certain file

Hi experts cp bin root src /mnt but not copy bin/bigfile any help? ( I post this thread in the "redhat" forum wrongly, I don't know how to withdraw that question in that wrong forum) Thanks (6 Replies)
Discussion started by: yanglei_fage
6 Replies
dircmp(1)							   User Commands							 dircmp(1)

NAME
dircmp - directory comparison SYNOPSIS
dircmp [-ds] [-w n] dir1 dir2 DESCRIPTION
The dircmp command examines dir1 and dir2 and generates various tabulated information about the contents of the directories. Listings of files that are unique to each directory are generated for all the options. If no option is entered, a list is output indicating whether the file names common to both directories have the same contents. OPTIONS
The following options are supported: -d Compares the contents of files with the same name in both directories and output a list telling what must be changed in the two files to bring them into agreement. The list format is described in diff(1). -s Suppresses messages about identical files. -w n Changes the width of the output line to n characters. The default width is 72. OPERANDS
The following operands are supported: dir1 A path name of a directory to be compared. dir2 USAGE
See largefile(5) for the description of the behavior of dircmp when encountering files greater than or equal to 2 Gbyte ( 2**31bytes). ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of dircmp: LC_COLLATE, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. (Differences in directory contents are not considered errors.) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ SEE ALSO
cmp(1), diff(1), attributes(5), environ(5), largefile(5) SunOS 5.10 1 Feb 1995 dircmp(1)
All times are GMT -4. The time now is 08:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy