Tag Info

Hot answers tagged

43

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


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


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


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


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


11

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


10

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


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.


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

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

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.


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

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


8

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


7

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


7

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


7

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.


7

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)


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

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


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


6

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


6

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.


5

My two cent suggestion: you could use PAM to do this. E.g. Use some pam module as pam-mysql to store some of your users in mysql and pam_require to avoid that mysql-stored users can access other than sftp service. Start looking here: Modules/Applications available or in progress...


5

Take a look at the OpenSSH project. It has all the info you're looking for. Briefly, the SSH protocol permits the secure (encrypted) connection between two hosts. The ssh utility is a client program to log into a remote system using the SSH protocol, and it has a lot of other uses, too, like [reverse] tunneling/port forwarding/... sshd it's the server ...


5

Did you restart the sshd service after making the changes to /etc/ssh/sshd_config? sudo /etc/init.d/ssh restart Ensure the chroot directory for the sftp user (in this case /home/lenny) is owned by root, not the sftp user. chmod 755 is correct. Also, I would add the following two lines for additional security: Match User lenny ChrootDirectory ...


5

SFTP doesn't have a command to move files, only a rename command. In OpenSSH (the de facto standard implementation), this is implemented with the rename system call, which moves a file inside a filesystem. There is no command that can move a file to an arbitrary location, nor is there a command to copy a remote file to another remote location. With only ...


5

In addition to Stephane's answer I'd like to point out that there is FTPS, too. FTPS is the classic FTP protocol over an SSL-secured connection. If you meant this you'd have to adjust your question of course, but it would be a completely different question then. There are two variations of FTPS, one were the control channel is secured (credentials etc) and ...


5

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


5

First, we see some information from man sftp: DESCRIPTION sftp is an interactive file transfer program, similar to ftp(1), which performs all operations over an encrypted ssh(1) transport. It may also use many features of ssh, such as public key authentication and compres‐ sion. sftp connects and logs into the specified host, then ...



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