quick introduction to ssh/scp in linux


These are just some most common command for dealing with ssh in Linux.

First, let’s make sure we have ssh (in Ubuntu and most all linux distribution it should be already included):

elect@elect-laptop:~$ ssh

If we get something like this, it is fine

usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-e escape_char] [-F configfile]
[-i identity_file] [-L [bind_address:]port:host:hostport]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R [bind_address:]port:host:hostport] [-S ctl_path]
[-w local_tun[:remote_tun]] [user@]hostname [command]

Now, if I want to copy my file test.txt present in my home folder on server in the pippo directory where i know the credentials of user

elect@elect-laptop:~$ scp test.txt user@server:/pippo

Note: server can be also an IP address

If it is the first time, I will be asked something like

The authenticity of host ‘server (012.345.678.901)’ can’t be established.
RSA key fingerprint is z6:32:07:6e:05:45:45:07:0e:01:2a:ca:0b:5b:b7:fg.
Are you sure you want to continue connecting (yes/no)?

Just time yes and continue

Then it is time for the password

user@server’s password:

Type it, and this is the result:

elect@elect-laptop:~$ scp text.txt user@server:/pippo
user@server’s password:
test.txt 100% 756KB 755.9KB/s 00:00

To transfer an entire directory

elect@elect-laptop:~$ scp -r directory user@server:/pippo

The other way round for keep text.txt in my home directory….

elect@elect-laptop:~$ scp user@server:/pippo/text.txt .

Ps: note the dot “.” at the end

….. or a directory

elect@elect-laptop:~$ scp -r user@server:/pippo/directory .

if you want to move all files, the traditional asterisked ” * ” is always valid 🙂

One thought on “quick introduction to ssh/scp in linux


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...