Hot answers tagged

93

I don't know why sftp does this but you can only recursive copy if the destination directory already exists. So do this... sftp> mkdir bin sftp> put -r bin


29

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


26

The SSH protocol is defined by what the ssh and sshd programs accept. (There is a standard defined for it, but it's an after-the-fact thing and is mostly ignored when one of the implementations adds new features.) Since there are multiple implementations of those (OpenSSH, F-Secure, PuTTY, etc.) occasionally you'll find that one of them doesn't support the ...


26

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


21

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


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

Pass the user name through the -o User option, or through the equivalent User directive in the client configuration file (~/.ssh/config). sftp -o Port:8777 -o User=user@domain.com domain.com This applies to ssh, scp and sshfs as well. Using the configuration file instead of -o options has the advantage of also working with tools that call ssh and don't ...


15

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


12

You might be interested in using rsync instead. The command for that would be rsync --delete --rsh=ssh -av bin/ remote-ip-or-fqdn:/home/earlz/blah/bin/ This will copy everything in bin/ and place it in on the remote server in /home/earlz/blah/bin/. As an added benefit, it will first check to see if the file on the remote side hasn't changed, and if it ...


12

sftp, like cp and scp, requires that when you copy a folder (and its contents, obviously), you have to explicitly tell it you want to transfer the folder recursively with the -r option. So, add -r to the command.


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

$ inotifywait -m /tmp Setting up watches. Watches established. /tmp/ CREATE file.ext.filepart /tmp/ OPEN file.ext.filepart /tmp/ MODIFY file.ext.filepart /tmp/ CLOSE_WRITE,CLOSE file.ext.filepart /tmp/ CREATE file.ext /tmp/ DELETE file.ext.filepart Transcript from running $ echo hello >/tmp/file.ext.filepart $ ln /tmp/file.ext.filepart /tmp/file.ext ...


9

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


9

SSH (stands for "Secure SHell") is a network protocol which described in RFC4251. ssh utility is SSH client that connects to SSH daemon and presents "Secure SHell" to user. SFTP is FTP-like protocol which works over SSH connection. su command does not use ssh or sshd in any way, it just allows you to run processes with different privileges.


9

Put it simple: SFTP = SSH + SFTP-server on server SCP = SSH + `scp` on server side FISH = SSH + `dd` (and some other basic Unix utilities on the server side only)


9

You got the right return code, sftp session executed correctly so the return code is 0. You should use scp instead, it does not returns 0 if it fails to copy. You could do something like : file=file_pattern`date -d "last month" +%m%Y`.csv remote=USER@remote.server.com:/rsdir1/rsdir2/rsdir3/$file local=/rsdir1/rsdir2/rsdir3/$file if scp -q $remote ...


9

You probably have some non-printable characters on end of lines (eg. CRLF from Windows), run: cat -A scriptname on remote machine, it'll show you all characters in your script. Then, you can convert to unix-like format running dos2unix scriptname


8

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.


8

You can use fish (files transferred over shell protocol). There are various client implementations, but none require any server support beyond regular SSH.


8

May I suggest a somewhat complicated answer, without zipping, but including tar? Here we go: tar -cf - ./bin | ssh target.org " ( cd /home/earlz/blah ; tar -xf - ) " This will pack the directory ./bin with tar (-cf:=create file), filename - (none, stdout) and pipe it through the ssh-command to target.org (which might as well be an IP) where the command ...


8

I can only suggest, you use rsync. It is somewhat of an industry standard, when moving files over secure connections. rsync -alPvz ./source_dir server.com:destination_dir It is what I've been using for years by now. (the -a option takes care of things like directory recursion)


8

Authentications that can continue: publickey The first instance of the “Authentications that can continue” message only lists public keys. So the server is set up not to accept any other authentication method such as passwords. If the server accepted passwords as well, you'd instead see: Authentications that can continue: publickey,password ...


8

SFTP is not FTP. It's the sftp subsystem of ssh, it's handled by the sshd daemon, not vsftpd or any FTP server. It's on the ssh TCP port (22), not the FTP port 21 (well FTP commands are on 21 while data connections are on arbitrary ports, and those multiple connections in FTP are one of the many reasons why SFTP is so much better than FTP). ss -lp sport = ...


8

For SSH: tar czf - . | ssh remote "( cd /somewhere ; cat > file.tar.gz )" For SFTP: outfile=/tmp/test.tar.gz tar cvf $outfile . && echo "put $outfile" | sftp remote:/tmp/ Connecting to remote... Changing to: /tmp/ sftp> put /tmp/test.tar.gz Uploading /tmp/test.tar.gz to /tmp/test.tar.gz /tmp/test.tar.gz Another SFTP: ...


7

It looks like there's no option for this with the OpenSSH SFTP client. You could use the PuTTY psftp command line tool instead, as its put and mput commands accept a -r (recursive) flag. It's in the putty-tools package under Debian (and most likely Ubuntu). Alternately, Filezilla will do what you want, if you want to use a GUI.


7

Remove Read access. Read access on a directory means that you can see a listing of files within that directory. Execute (X) access means you can cd into the directory or traverse it Write access means that you are able to add or change items within the directory.


7

The best way, is to use SFTP from SSH and jail the user. in file: /etc/ssh/sshd_config make sure this line is uncomented: Subsystem sftp internal-sftp Then configure the rule to match a group: Match group sftponly ChrootDirectory /home/%u X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp and lastly ...


7

There is no mv command in the interactive mode of sftp. Use rename instead. To learn which commands are available, check the man page man sftp or type help within sftp.


7

There are 3 avenues that I can conceive of that might provide you with a solution. 1. Custom sftp Subsystem You could wrap the sftp-server daemon via sshd_config and "override" it with your own script that could then intercept what sftp-server is doing, and then act when you see that a file was downloaded. Overriding the default sftp-server in sshd_config ...


6

SSH is a protocol for secure communication over an insecure network. It allows for end to end encryption of all communication such that it cannot (feasibly) be intercepted and decrytped. ssh the utility is an implementation of the protocol. SFTP is a subsystem of ssh that uses the protocol for secure password and file transfer. su does not use the ssh ...



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