-
Notifications
You must be signed in to change notification settings - Fork 0
/
copying-files-from-one-unix-box-to-another-with-scp.html
134 lines (127 loc) · 5.29 KB
/
copying-files-from-one-unix-box-to-another-with-scp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Dreams of thought</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/theme/styles.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="/theme/slicknav.css">
<script src="/theme/jquery.slicknav.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script>
<![endif]-->
<script>
$(function(){
$('#menu').slicknav({'label':''});
});
</script>
<link rel="icon" href="/theme/favicon.ico" sizes="16x16 32x32 48x48 64x64" type="image/vnd.microsoft.icon">
<link rel="apple-touch-icon" sizes="114x114" href="/theme/apple-touch-icon-precomposed.png">
<link rel="apple-touch-icon" sizes="152x152" href="/theme/favicon152.png">
<link rel="apple-touch-icon" sizes="196x196" href="/theme/favicon196.png">
</head>
<body>
<div id="wrapper">
<header>
<nav class="byline"><ul id="menu">
</ul></nav><!-- /#menu -->
<div class="downloads">
<a href="#" class="fa fa-Twitter"></a>
<a href="#" class="fa fa-Github"></a>
</div>
<hgroup>
<h1>Copying files from one unix box to another with scp</h1>
<footer class="article-footer">
<address class="vcard author">
By <a class="url fn" href="./author/admin.html">admin</a>
</address>
<abbr class="published" title="2009-07-31T11:23:00+05:30">
on 31.07.2009
</abbr>
</footer><!-- /.post-info -->
</hgroup>
<meta name="tags" contents="Linux" />
<meta name="tags" contents="rcp" />
<meta name="tags" contents="scp" />
<meta name="tags" contents="ssh" />
<meta name="tags" contents="unix" />
<meta name="tags" contents="technology" />
</header>
<section id="content" class="body article">
<div class="entry-content">
<p>ssh is a very powerful and widely used protocol in all the Unices. If
you've used the ssh client in your Unix/Linux box, you must have
realised how indispensable it is. There is another indispensable tool
that uses the ssh protocol - scp (secure copy). scp was meant to be an
alternative to unsecure tools like rcp. It has since replaced most such
programs. Since scp uses the ssh protocol, the encryption it uses
ensures security of your data.</p>
<div class="line-block">
<div class="line">Using scp is simple. It works almost like the regular cp command. The
basic syntax is</div>
<div class="line-block">
<div class="line"><tt class="docutils literal">scp SOURCE DESTINATION</tt></div>
<div class="line">In order to specify the SOURCE or DESTINATION we have a special
syntax.</div>
<div class="line"><tt class="docutils literal">USERNAME@HOST:PATH</tt></div>
</div>
</div>
<div class="line-block">
<div class="line">Let me give you an example :
<tt class="docutils literal">$scp <span class="pre">anirudh@box:/var/www/html/test.html</span> <span class="pre">gingerjoos@linux:~/test_dir/</span></tt></div>
<div class="line">Copy /var/www/html/test.html in the machine called "box" as user
"anirudh" to the box called "linux" as user "gingerjoos" to the path
HOMEDIR/test_dir/</div>
</div>
<p>That's it :) Simple, right?</p>
<div class="line-block">
<div class="line">To copy the file to our localmachine, we could do this</div>
<div class="line"><tt class="docutils literal">$scp <span class="pre">anirudh@box:/var/www/html/test.html</span> ~/workarea/</tt></div>
</div>
<p>This would copy the file test.html in the machine called "box" (as user
anirudh) to the localmachine at path HOMEDIR/work_area/</p>
<p>Interchange the source-destination to copy file in your localmachine to
the remote machine.</p>
<div class="line-block">
<div class="line">If you want to copy whole directories, use the '-r' flag(recursive
copy)</div>
<div class="line-block">
<div class="line"><tt class="docutils literal">$scp <span class="pre">-r</span> ~/workarea/ <span class="pre">anirudh@box:~/workdir/</span></tt></div>
</div>
</div>
<p>Since scp is tied to the ssh program, the keys you use to set up
passwordless login with ssh works for scp as well.</p>
<p>Got questions? Got something to add to this? Post your comments below :)</p>
</div><!-- /.entry-content -->
<div class="article-share-tags">
<div class="end-article-tags">
<i class="fa fa-tags"></i>
<a href="./tag/linux.html">Linux</a>
<a href="./tag/rcp.html">rcp</a>
<a href="./tag/scp.html">scp</a>
<a href="./tag/ssh.html">ssh</a>
<a href="./tag/unix.html">unix</a>
<a href="./tag/technology.html">technology</a>
</div>
<div class='article-share'>
share -
</div>
</div>
</section>
<div class="neighbors">
</div>
<footer>
<a href="./pages/about.html" >About</a>
<div class="right-footer">
<a href="./categories.html" >Categories</a>
<a href="./tags.html" >Tags</a>
</div>
</footer>
</body>
</html>