Tag Info

Hot answers tagged

32

You can pipe tar across an ssh session: $ tar czf - <files> | ssh user@host "cd /wherever; tar xvzf -"


28

Newer versions of scp have the option -3 -3 Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts


25

You can set that user's shell to rssh or scponly, which are designed precisely for that purpose: rssh is a restricted shell for use with OpenSSH, allowing only scp and/or sftp. It now also includes support for rdist, rsync, and cvs. scponly is an alternative 'shell' (of sorts) for system administrators who would like to provide access to remote ...


25

Try this line: readlink -f `which command` If command is in your $PATH variable , otherwise you need to specify the path you know.


25

You need to pass a literal escape to scp to avoid the remote machine treating * as a glob (notice that it is doubly quoted): scp 'SERVERNAME:/DIR/\*' .


21

As you say, use rsync: rsync -azP /var/www/html/txt/ username@ip-address:/var/www/html/txt The options are: -a : enables archive mode, which preserves symbolic links and works recursively -z : compress the data transfer to minimise network usage -P : to display a progress bar and enables you to resume partial transfers As @aim says in his answer, make ...


19

You can use the advanced globbing patterns in some shells to match all the files in a directory except for those matching a particular pattern. For example, in ksh, bash or zsh, the command shopt -s extglob ## needed in bash only setopt ksh_glob ## needed in zsh only mv /source/!(*.bak) /destination will move all files in /source to /destination ...


19

A regular file is a file that isn't a directory or more exotic kinds of “special” files such as named pipes, devices, sockets, doors, etc. Symbolic links are not regular files either, but they behave like their target when it an application is accessing the content of the file. You passed root@IP: as the source of the copy and /path/to/picture.jpg as the ...


18

SFTP isn't the FTP protocol over ssh, but an extension to the SSH protocol included in SSH2 (and some SSH1 implementations). SFTP is a file transfer protocol similar to FTP but uses the SSH protocol as the network protocol (and benefits from leaving SSH to handle the authentication and encryption). SCP is only for transferring files, and can't do other ...


18

scp provides a cp like method to copy files from one machine to a remote machine over a secure SSH connection. rsync allows you to syncronise remote folders. They are different programs and both have their uses. scp is always secure, whereas rsync must travel over SSH to be secure.


16

Ok LOL, I just figured out what the problem is. Since I like cows so much, I've put fortune | cowsay at the top of my .bashrc file which produces output like the following when starting bash: _______________________________________ < You will lose an important disk file. > --------------------------------------- \ ^__^ \ ...


16

If you did not have the foresight to launch the process with nohup, you can also background the process and disown the bash session while it is running. Open ssh terminal to remote server Begin scp transfer as usual Background the scp process (Ctrl+Z, then bg) Disown the backgrounded process (disown) Terminate the session (exit) and the process will ...


16

This is trivial to do with a little script. For example: for server in app0 app1 app4 app5 appN; do scp user@$server:/path/to/log/file /local/path/to/"$server"_file done The above will copy the file from each of the servers sequentially and name it SERVERNAME_file. So, the file from app0 will be app0_file etc. You can obviously change the names to ...


15

SSH Supports chrooting an SFTP user natively. You just need to supply ChrootDirectory In your sshd config file, and restart sshd. If you are just doing sftp, then you don't have to do anything more. Unfortunately, this doesn't work for scp. For interactive shell, you will need to copy binaries, and /dev nodes into the chroot. An example config, for ...


15

There are many ways to do what you want. The simplest is to use a pìpe: tar zcvf - MyBackups | ssh user@server "cat > /path/to/backup/foo.tgz" Here, the compression is being handled by tar which calls gzip (z flag). You can also use compress (Z) and bzip (j). For 7z, do this: tar cf - MyBackups | 7za a -si -mx=9 -ms=on MyBackups.tar.7z | ssh ...


13

You can connect to the host using sftp -r and then get the directory. If you forget to use -r when you connect, you can use get -r. sftp -r me@somehost Or sftp> get -r tmp/ Fetching /home/me/tmp/ to tmp Retrieving /home/me/tmp /home/me/new.orig.dmp 100% 417KB 416.8KB/s 00:00 /home/me/untangle.dmp 100% 398KB 398.3KB/s 00:00 ...


13

When copying a directory u need to use a -r option: scp -r root@IP:/path/to/file /path/to/filedestination


12

Tar with bzip2 compression should take as much load off the network and on the cpu. $ tar -C /path/to/src/dir -jcf - ./ | ssh user@server 'tar -C /path/to/dest/dir -jxf -' Not using -v because screen output might slow down the process. But if you want a verbose output use it on the local side of tar (-jcvf), not on the remote part. If you repeatedly copy ...


12

You did't specify any file: you have to add the file (with path) after the colon A$ scp @hostB:/absolutepath/file . or A$ scp @hostB:relativepath/file . for a path relative to your home directory. If you don't specify a different user (i.e., the user on A and B are the same) you don't need the @ A$ scp hostB:/path/file .


11

You should quote your file name two times, one for the local shell and one for the remote one. In the simplest case you can do one of the following scp -r -P 8484 root@172.31.72.103:"'/media/New Volume/lj'" /home/pratheep scp -r -P 8484 root@172.31.72.103:'"/media/New Volume/lj"' /home/pratheep or using the help of tab completion scp -r -P 8484 ...


11

You forgot the destination. scp alex@192.168.0.4:ipdetect-0.6.tar.bz2 .


10

There are a few methods. The simplest way if you're just transferring a file once in a while. scp myfile.txt user@example.com:/home/user/ scp stands for secure copy and it transfers over SSH. There is also sftp sftp user@example.com > cd /home/user/ > put myfile.txt I guess the only real advantage to using this is that you can transfer multiple ...


10

pdcp from the pdsh package is one option. pdsh was written to help with management of HPC clusters - I've used it for that, and I've also used it for management of multiple non-clustered machines. pdsh and pdcp use genders to define hosts and groups of hosts (a "group" is any arbitrary tag you choose to assign to a host, and hosts can have as many tags as ...


9

I found Patrick's advice to be correct, although Chris's answer got me on the right track. Use quotes and then you don't need the backslash before the asterisk. scp 'SERVERNAME:/tmp/file_num\*' . scp: /tmp/file_num*.csv: No such file or directory scp 'SERVERNAME:/tmp/file_num*' . judgments_for_job_171642.csv 100% 32KB 32.0KB/s 00:00 ...


9

In the sshd config man page man 5 sshd_config: MaxAuthTries Specifies the maximum number of authentication attempts permitted per connection. Once the number of failures reaches half this value, additional failures are logged. The default is 6. So a setting of MaxAuthTries 2 will be the setting you will need. sshd will need to be ...


8

FISH and SFTP are similar, and as observed do both work over SSH, SFTP requires specific support and configuration in the SSH Server to facilitate the transfer, but it a bit more secure and allows for SysAdmins to only allow SFTP (in these situations FISH won't work). FISH requires a shell (sh/rsh for instance) to copy, and hence requires full SSH access to ...


8

A chroot is a reasonably simple method. Since the operating system already has this security feature, daemon writers tend not to attempt to reimplement it. Rssh comes with a guide on setting up a chroot jail. It's in the CHROOT file in the source distribution. In a nutshell, you need to have: A few binaries, copied from the root: /usr/bin/scp, ...


8

try this. should work with recent versions of xargs. svn st | awk '{print $2}' | xargs -iz scp z my_name@my_server: alternately, you could just loop though the files. for file in $(svn st | awk '{print $2}'); do scp $file my_name@my_server: ; done


8

As root, set up a named pipe: # mkfifo /tmp/fifo # chmod o+w /tmp/fifo Then, transfer your data as me: $ tar cfzp - foldertocopy | ssh me@machine "cat > /tmp/fifo" But read it as root: # tar -xfzp /tmp/fifo



Only top voted, non community-wiki answers of a minimum length are eligible