Hot answers tagged

102

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


31

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

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


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


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


19

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


14

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


13

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.


12

CORRECTED: I initially claimed wrongly that OpenSSH did not support put -r. It does, but it does it in a very strange way. It seems to expect the destination directory to already exist, with the same name as the source directory. sftp> put -r source Uploading source/ to /home/myself/source Couldn't canonicalize: No such file or directory etc. ...


11

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

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

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

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

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)


9

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


9

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.


9

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


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


9

In /etc/ssh/sshd_config add the following: AllowUsers remoteUserA@xx.xx.xx.xx remoteUserA@yy.yy.yy.yy userA AllowUsers remoteUserB@zz.zz.zz.zz userB Then restart the SSH daemon. You can use wildcards as described in Patterns section of the ssh_config manual.


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

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


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

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

From the here-string (<<<) syntax you used I guess your shell is bash, so you can also use string with backslash-escaped characters ($''): sftp -o PasswordAuthentication=no user@host <<< $'lcd /home\n cd /myhome\n get file' The portable alternative is here-document: sftp -o PasswordAuthentication=no user@host <<END lcd /home cd ...


8

Question #1 My question is, how do I restrict the command to just this SFTP transfer in the public key that is generated? There are 2 methods for doing this. 1. -- Restricting through sshd This method involves setting up the SFTP feature within your SSH daemon, sshd. This is controlled through the /etc/ssh/sshd_config configuration file. NOTE: ...


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.



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