[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Transferring files over SSH in the console

On Mon, Mar 22, 2010 at 01:02:10AM +0200, Dotan Cohen wrote:
> On 22 March 2010 00:57, Selçuk Mıynat <selcukmiynat@gmail.com> wrote:
> > On Mon, Mar 22, 2010 at 00:52, Dotan Cohen <dotancohen@gmail.com> wrote:
> >> I am managing a small embedded device that I SSH into over the LAN. To
> >> run commands, I use KDE Konsole, and to transfer files I use Konqueror
> >> and SFTP. I understand that SFTP also runs over SSH, so is there a way
> >> to send files in Konsole as well? I am familiar with the FTP commands
> >> such as cd, lcd, put, and get. Are there equivalent commands for SSH
> >> terminal connections?
> >
> > Are you looking for scp?
> >
> > http://en.wikipedia.org/wiki/Secure_copy
> > http://www.helpdesk.umd.edu/documents/4/4801/
> >
> No, scp is for sending files to a remote machine that the user has yet
> to connect to:
> localhost$ scp /path/to/file.txt user@remoteMachine /remote/path/

(wrong syntax: scp /path/to/file.txt user@remoteMachine:/remote/path/ )

While this is not what you asked for, I still prefer scp.
scp can be made much more convinient to use, once you allow tab
completion of remote file names.

 scp file.txt user@remoteMachine:/rem<tab>

This works if you cna login without a password to user@remoteMachine .
There are several ways to do that:

1. Passphrase-less key
2. key + ssh-agent

I suppose people in this list are familiar with the above two. The
down-sides with those two are:

1. They still require estabilishng an extra SSH connection per pressing
of <tab>.
2. They may require extra setup on remoteMachine.

Luckily openssh provides a better alternative. In my .ssh/config I have:

Host *
        ControlMaster = auto
        ControlPath = ~/.ssh/socket/control_%h__%p__%r__%l

This means that whenever I connect to a new host, ssh creates a socket
that allows multiplexing new ssh connections on the already-established
SSH connection. After-all the SSH protocol was designed to support
multiple streams (for e.g. port forwarding).

With this set, scp works nice and fast to a remote host. BTW: it seems
that in squeeze rsync now has the same sort of completion.

As usual, I rely on the shell's history to provide me some sort of
context. I usually also copy pathes from a remote shell window on the
target system.

Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend

Reply to: