Tag Info

Hot answers tagged

24

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


16

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


15

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


14

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.


12

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


12

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


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


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


8

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


7

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


7

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


7

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 .


7

To open file using path relative to username's home directory run, vim scp://username@remotehost/file which is same as, vim scp://username@remotehost//home/username/file If you want to enter the absolute path to a file starting from / instead of your home directory, use two slashes after the host name run, vim ...


7

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


6

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


6

use rsync, it uses SSH. Usage: rsync -aPz /source/path destination.server:remote/path The rsync switches care about compression and I-Node information. -P displays progress of every file. You can use scp -C, which enables compression, but if possible, use rsync.


6

You might want to look at scponly; it's essentially a login shell that can only be used to launch scp or the sftpd subsystem. In the scponlyc variant it performs a chroot before activating the subsystem in question.


6

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


5

There are many ways to skin this cat. Here are some for you to consider: The htdocs tree almost certainly doesn't have to be owned by root. What matters is that it be readable by the Apache user. Depending on the *ix system in question, that may be apache, www-data, or something else. The default file mode you give above, drwxr-xr-x (abbreviated 755) is ...


5

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


5

A little diagnosis: from this debug1: Sending command: scp -v -r -p /PATH/TO/DIR root@SERVER2:/PATH/TO/DIR [...] debug1: read_passphrase: can't open /dev/tty: No such device or address I'd suspect (guess) it works this way, the server-to-server copy with scp logs into SERVER1 and executes the scp command to send the file to SERVER2; thus the caller (from ...


5

Your commands are trying to put the new Document to the root (/) of your machine. What you want to do is to transfer them to your home directory (since you have no permissions to write to /). If path to your home is something like /home/erez try the following: scp My_file.txt user_id@server:/home/erez/ You can substitute the path to your home directory ...


5

General advice is to use terminal multiplexer (e.g. tmux or screen) and run the copy inside, since that gives one much flexibility. You can detach/reattach as necessary to check how the operation proceeds. These programs create "virtual" (headless) terminals which are displayed on/take input from a "real" terminal (linux console, X terminal emulators, ssh ...


4

To simplify your setup, you can set up an SSH config file which is located at ~/.ssh/config. Add an entry to the file like: Host server User l33t HostName server.example.org The HostName directive is optional if it matches the name given in Host. This is basically an alias to typing l33t@server.example.org. You could make the name as short a s in the ...


4

The umask, in the way you mean it, is a property of the login shell. It is set in .profile or one of its relatives. Since scp doesn't log in interactively, it doesn't run any of these scripts, so it doesn't get the umask setting you've defined there. The closest thing I can think of to what you want is to set the permissions appropriately on the file ...


4

Your shell would've expanded the * to all files in the current directory. scp takes multiple source files and a single destination path (the same as cp), so it will have copied username@server.com:~/SomeDirectory/Subdir/* and all the files in the current directory except the last one, to the last one. So, assuming the file list in the current directory ...


4

Methods such as creating the file /etc/nologin, setting account login shells to /bin/false or /sbin/nologin effectively disable user accounts from logging into an interactive shell, but do not protect the system. If you want to specifically restrict a user to using scp or sftp only, install a restricted shell that is designed to do exactly that. The rssh ...



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