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
createhomedir(1)					    BSD General Commands Manual 					  createhomedir(1)

NAME
createhomedir -- create and populate home directories on the local computer. SYNOPSIS
createhomedir [-scbalh] [-n directoryDomainName] [-u username] DESCRIPTION
createhomedir provides several options for creating and populating home directories. OPTIONS
-s creates home directories for server home paths only (default). -c creates home directories for local home paths only. -b creates home directories for both server and local home paths. -a creates home directories for users defined in all directory domains of the server's search path. -l creates home directories for users defined in the local directory domain. -n directoryDomainName creates home directories for users defined in a specific directory domain in the server's search path. -u username creates a home directory for a specific user defined in the domain(s) identified in the -a, -l, or -n parameter. If you omit the -a, -l, and -n parameters when you use the -u parameter, -a is assumed. -i reads username list from standard input and creates specified home directories. Each username should be on its own line. -h usage help. FILES
/usr/sbin/createhomedir location of tool CAVEATS
When using the -a option, search limits of various directory servers (such as Open Directory or Active Directory) can prevent all possible home directories from being created. In this case, you may need to specify the usernames explicitly. Mac OS X June 1, 2019 Mac OS X
All times are GMT -4. The time now is 11:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy