Linux / UNIX: scp / rsync File Name With a Colon (:) In It

How do I copy a file with a colon punctuation (:) name in it. When I type the following command to copy “file:name.txt” to a remote host called server1:

scp file:name.txt user@server1:/path

I get the following error:

ssh: Could not resolve hostname s: Name or service not known

How do I copy file with scp or rsync with a colon in it?

[donotprint][/donotprint]Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing : as host specifiers. In other words use the following syntax:
scp ./file:name.txt user@server1:/path/to/dest

OR

scp /path/to/src/file:name.txt user@server1:/path/to/dest

OR

rsync /path/to/src/file:name.txt user@server1:/path/to/dest

In this example, I am coping a file called mysql-blog-db.23-02-2014-11:10:06.gz to a server called backup-test-server13

rsync 'mysql-blog-db.23-02-2014-11:10:06.gz' vivek@backu-test-server13:~

Sample error/outputs:

The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at /SourceCache/rsync/rsync-42/rsync/main.c(1083) [receiver=2.6.9]

You will get same result with scp command

scp 'mysql-blog-db.23-02-2014-11:10:06.gz' vivek@backu-test-server13:~

Sample error/outputs:

ssh: Could not resolve hostname mysql-blog-db.23-02-2014-11:10:06.gz: nodename nor servname provided, or not known

How do I scp/rsync a file name with a colon?

In this example, I am coping a file called mysql-blog-db.23-02-2014-11:10:06.gz to a server called backup-test-server13 using scp command:

scp ./mysql-blog-db.23-02-2014-11:10:06.gz vivek@backu-test-server13:~

OR

scp /tmp/mysql-blog-db.23-02-2014-11:10:06.gz vivek@backu-test-server13:~

OR pass some additional options:

scp -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/vivek/.ssh/my-keys -P 22 ./mysql-blog-db.23-02-2014-11:10:06.gz vivek@backu-test-server13:~

Sample outputs:

Warning: Permanently added '173.xx.yy.zz' (RSA) to the list of known hosts.
mysql-blog-db.23-02-2014-11:10:06.gz

Here is syntax for rsync command:

rsync -av ./foo:bar:file.txt user@server1.sxi.io:/tmp
rsync -av $HOME/data/foo:bar:file.txt user@server1.sxi.io:/tmp

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts