天道酬勤,学无止境

scp

Getting an error EOF : Command no found when using ssh

Question I am trying to rename the filenames in remote server like filename-dirname.suffix and copy the files to my server . I had written code like .... #!/usr/bin/bash TRANSFERSERVERXMLS="/emp/transfer/XMLS" REMOTESERVERXMLS="remoteemp/empdir/XMLS" # renaming the filenames in remote server like filename-dirname.suffix ssh abc@xyz REMOTESERVERXMLS=$REMOTESERVERXMLS 'bash -s'<< 'EOF' for i in $REMOTESERVERXMLS/* ; do if [[ -d $i ]]; then dirname=$(basename $i) for j in $REMOTESERVERXMLS/$dirname/* ; do fname="$(basename "$j")" prefix=$(echo $fname | awk -F "." 'NF{NF-=1};1') suffix=$(echo

2021-12-03 10:48:51    分类:技术分享    bash   unix   ssh   sh   scp

Paramiko / scp - check if file exists on remote host

Question I'm using Python Paramiko and scp to perform some operations on remote machines. Some machines I work on require files to be available locally on their system. When this is the case, I'm using Paramiko and scp to copy the files across. For example: from paramiko import SSHClient from scp import SCPClient ssh = SSHClient() ssh.load_system_host_keys() ssh.connect('192.168.100.1') scp = SCPClient(ssh.get_transport()) scp.put('localfile', 'remote file') scp.close() ssh.close() My question is, how can I check to see if 'localfile' exists on the remote machine before I try the scp? I'd like

2021-11-30 06:32:12    分类:技术分享    python   python-2.7   ssh   scp   paramiko

nohup causes "read_passphrase: can't open /dev/tty"

Question I have a simple remote ssh command in script, nohupssh.sh sleep 30 ssh -v -l developer server11 "/usr/local/jdk1.7.0_45/bin/jmap -histo:live 1770;" I run the script as follows: nohup nohupssh.sh > out.log 2>&1 & When I execute it as shown above, the jmap utility successfully executes on the remote server. However, if I execute it as shown above and exit the bash shell, I get the error shown below. Note that I have a properly formatted authorized_keys in both local and remote servers. Also note that there is NO id_rsa in either server since these servers are shared. I've tried many

2021-11-28 05:24:55    分类:技术分享    ssh   scp   nohup

How to deploy from git repo without server having access to repo?

Question I have a PHP project in a BitBucket git repo. I work in a branch called "develop" for small fixes, or I work in temporary feature branches. When I'm ready to deploy, I merge those branches into "master". I want to make deploying to my live site as easy as that (merging to master and pushing to BitBucket). But I really don't want my server to have any access to my repo because that adds security concerns. If you care about security, you want your repo to be in as few places as possible. If your server gets compromised, that's a bad enough situation, but it would be even worse if the

2021-11-27 06:25:03    分类:技术分享    git   deployment   rsync   scp

Using Mercurial, is there an easy way to diff my working copy with the tip file in the default remote repository

Question When using mercurial, I'd like to be able to diff the working copy of a file with the tip file in my default remote repository. Is there an easy way to do this? I know I can do an "hg incoming -p" to see the patch sets of changes coming in, but it'd be nice to just directly see the actual changes for a particular file that I'd get if I do a pull of the latest stuff (or what I might be about put push out). The easiest thing I can think of right now is to create a little script that takes a look at the default location in .hg/hgrc and downloads the file using curl (if it's over http

2021-11-26 13:49:55    分类:技术分享    svn   http   mercurial   diff   scp

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

Question 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? Answer1 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 you don't have nc you can do it with ssh -W if your version is new enough (>= OpenSSH 5.4)

2021-11-19 16:18:03    分类:技术分享    linux   bash   shell   ssh   scp

copying logs in python using the command line function

Question 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) filePath = root_path + folder_name serverPath = "/var/log/apache/*" cmd = "scp " + "symentic@60.62.1

2021-11-18 16:21:35    分类:技术分享    python   automation   scp

Bash script to find specific files in a hierarchy of files

Question I have a folder in which there are many many folder and in each of these I have lots and lots of files. I have no idea which folder each files might be located in. I will periodically receive a list of files I need to copy to a predefined destination. The script will run on a Unix machine. So, my little script should: read received list find all files in the list copy each file to a predefined destination via SCP step 1 and 3, I think I'll manage on my own, but how will I do step 2? I was thinking about using "find" to locate each file and when found, write the location in a string

2021-11-15 14:57:42    分类:技术分享    bash   unix   find   scp

Using Volumerize to backup my docker volumes with scp ?

Question I have a couple of docker volumes i want to backup onto another server, using scp/sftp. I don't know how to deal with that so i decided to have a look at blacklabelops/volumerize GitHub project. This tool is based on the command line tool Duplicity. Dockerized and Parameterized for easier use and configuration. Tutorial is dealing with a jenkins docker, but i don't understand how to mention i'm want to use a pem file. I've tried different solution (adding -i option to scp command line) without any success at the moment. Duplicity man page is mentioning the use of cacert pem files (-

2021-11-14 06:12:42    分类:技术分享    docker   backup   scp   docker-volume

Transfer file(scp) and run command from jumpserver to finalserver using python script on localhost

Question A file needs to be uploaded to final-server and a command needs to be run using that file as input. Following will be the steps for whole action to be performed (but I am stuck at step 3): 1 - transfer file from localhost to jumpserver (using scp) 2 - ssh to jumpserver 3 - transfer file from jumpserver to finalserver (using scp) 4 - ssh to finalserver 5 - run the command on finalserver (with file as input) try: cmd_str = "scp " + file_path + " " + user + "@" + jumpbox + ":/tmp/" print "---------local to jumpbox initiated:" #print cmd_str child = pexpect.spawn(cmd_str) #---------------

2021-11-12 15:34:47    分类:技术分享    python   ssh   scp   pexpect