scp

shell-scp命令

怎甘沉沦 提交于 2019-12-14 08:47:22
scp -P 端口 c://xxxx.txt user@ip:/home/root 注意: -P 大写 -i 公钥 1、从服务器上下载文件 scp username@servername:/path/filename /var/www/local_dir(本地目录) 例如scp root@192.168.0.101:/var/www/test.txt 把192.168.0.101上的/var/www/test.txt 的文件下载到/var/www/local_dir(本地目录) 2、上传本地文件到服务器 scp /path/filename username@servername:/path 例如scp /var/www/test.php root@192.168.0.101:/var/www/ 把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中 3、从服务器下载整个目录 scp -r username@servername:/var/www/remote_dir/(远程目录) /var/www/local_dir(本地目录) 例如:scp -r root@192.168.0.101:/var/www/test /var/www/ 4、上传目录到服务器 scp -r local_dir username

how to transfer data between local and remote server connected via intermediate server?

可紊 提交于 2019-12-14 03:29:12
问题 I can login by ssh -X servA from local , then ssh -X servB from servA To copy data from local to servB , I scp files from local to servA , then from servA to servB . Is it feasible to copy files from local to servB directly and vice versa? 回答1: You can use nc (net cat) as a proxy for ssh. So for your example, edit your ~/.ssh/config file to look like this: Host servB ProxyCommand ssh -q servA nc servB 22 As long as nc is in your path you should now be able to ssh or scp directory to servB If

Problem with scp on Mac OS X: scp doesn't like spaces in filenames, “\” fix doesn't work

丶灬走出姿态 提交于 2019-12-14 00:21:06
问题 I am trying to use scp to transfer files between two Macs (OS 10.6.8). But it fails because there are spaces in my directory/file names. I can't change the directory/file names. I have often used a \ symbol when working in a terminal with my Macs to represent spaces. In this case, however, it is not working. I would very much appreciate any tips on how to deal with this. Thanks. Here is an example of what I'm doing, in case I'm making a silly mistake somewhere: scp -r me@myWork:../../My\

how to give user name and password as a input in scp module?

拟墨画扇 提交于 2019-12-13 19:06:18
问题 I am trying to copy a files from one host to another host using : Net::SCP::Expect here is my program. use strict; use Net::SCP::Expect; print "enter user name\n"; my $username = <>; print "enter password\n"; my $pass = <>; print "enter host name\n"; my $host = <>; my $src_path = "/"; my $dst_path = "/"; my $scpe = Net::SCP::Expect->new(user=>$username, password=>$pass, auto_yes=> '1'); $scpe->scp($host.":".$src_path, $dst_path); I am getting error as bad password.how to give user name and

Object Oriented C++ library for ssh and scp

痞子三分冷 提交于 2019-12-13 12:03:55
问题 Is there any Object Oriented C++ library for ssh and scp. BSD license would be preferred. I could find libssh and libssh2. But these are all procedural. 回答1: With libssh version 0.5 the library comes with a nice C++ wrapper. It's in the include directory and called libsshpp.h I hope this will suite your needs. Else open a feature request. 回答2: Take a look at NetSieben SSH Library - an open source ssh client library in C++: http://freshmeat.net/projects/net7ssh/ 回答3: I use cryptlib for this.

copying logs in python using the command line function

為{幸葍}努か 提交于 2019-12-13 08:07:12
问题 I had a doubt with my code which i think I can verify here . My requirement is to copy the apache log and error log from two different servers . Iv written down a python program, using a for loop. My code: def copylogs(Appache,Errorlog, folder_prefix) : root_path = '/home/tza/Desktop/LOGS/' folders = ['Appache','Errorlog'] for folder in folders: folder_name = folder_prefix + "_" + folder + str(int(time.time())) mkdircmd = "mkdir -p " + root_path + "/" + folder_name os.system(mkdircmd)

scp: how to find out that copying was finished

白昼怎懂夜的黑 提交于 2019-12-13 03:58:30
问题 I'm using scp command to copy file from one Linux host to another. I run scp commend on host1 and copy file from host1 to host2. File is quite big and it takes for some time to copy it. On host2 file appears immediately as soon as copying was started. I can do everything with this file even if copying is still in progress. Is there any reliable way to find out if copying was finished or not on host2? 回答1: Off the top of my head, you could do something like: touch tinyfile scp bigfile tinyfile

pass variable to find via ssh for -newermt option

谁说胖子不能爱 提交于 2019-12-13 02:22:32
问题 I am trying to copy a group of files within a certain time range from a remote server(server B) with a script run on a local server(Server A). I'm using the -newermt option in find to specify my time range. So if I ssh to the remote server(server B) this works: find /appl/backup/monsters/green/y.y.y.y/2016-04-26_08-00-01/jelly/ -newermt "2016-04-26 07:40:00" \! -newermt "2016-04-26 07:50:00" And I get the list of files for the times specified. However, If I try to involke this from the local

Actual return code for SCP

一笑奈何 提交于 2019-12-13 01:55:20
问题 I am writing a bash script that goes through a list of filenames and attempts to copy each file using scp from two servers into a local folder. The script then compares the local files to each other. Sometimes however, the file will not exist on one server or the other or both. At first, I was using this code: scp $user@$host:/etc/$file ./$host/conf/ 2>/tmp/Error 1>/dev/null error=$(</tmp/Error) # error catching if [[ -n "$error" ]]; then echo -e "$file not found on $host"; fi But I found