Tag Info

Hot answers tagged

33

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


29

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/\*' .


29

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


28

Rsync is very well suited for transferring large files over ssh because it is able to continue transfers that were interrupted due to some reason. Since it uses hash functions to detect equal file blocks the continue feature is quite robust. It is kind of surprising that your sftp/scp versions does not seem to support large files - even with 32 Bit ...


27

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


26

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

Use rsync with the --partial option rsync -av --partial sourcedir user@desthost:/destinationdir The --partial will keep partially transferred files. When you resume the rsync transfer after a ssh broken connection, partially transferred files will start resuming from the point where the ssh connection was lost, and also successfully transferred files will ...


23

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 ...


22

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 ...


22

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 ...


21

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 ...


20

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.


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

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. > --------------------------------------- \ ^__^ \ ...


19

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


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

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 ...


17

I'm not sure about the file size limits of SCP and SFTP, but you might try working around the problem with split: split -b 1G matlab.iso This will create 1 GiB files which, by default, are named as xaa, xab, xac, .... You could then use scp to transfer the files: scp xa* xxx@xxx: Then on the remote system recreate the originial file with cat: cat xa* ...


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

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 .


14

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

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 ...


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 ...


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

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, ...


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 ...


10

You need to run the scp command from the local machine, not on the remote. You don't need the ssh at all: dragonmnl@local $ scp -P 2222 file.ext username@domain:~/ You also don't need the -r: -r Recursively copy entire directories. If you are already logged into the remote machine and want to copy from your local, you need to make sure that ...



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