the secure shell copyright © software carpentry 2011 this work is licensed under the creative...
TRANSCRIPT
![Page 1: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/1.jpg)
The Secure Shell
Copyright © Software Carpentry 2011
This work is licensed under the Creative Commons Attribution License
See http://software-carpentry.org/license.html for more information.
The Unix Shell
![Page 2: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/2.jpg)
Unix Shell Secure Shell
$ pwd
shell
![Page 3: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/3.jpg)
Unix Shell Secure Shell
$ pwd
/users/vlad
$
shell
![Page 4: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/4.jpg)
Unix Shell Secure Shell
login as: vlad
Password: ********
shell
![Page 5: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/5.jpg)
Unix Shell Secure Shell
login as: vlad
Password: ********
$
shell
![Page 6: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/6.jpg)
Unix Shell Secure Shell
login as: vlad
Password: ********
moon>
shell
remote shell
![Page 7: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/7.jpg)
Unix Shell Secure Shell
login as: vlad
Password: ********
moon>
shell
remote shell
![Page 8: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/8.jpg)
Unix Shell Secure Shell
$ pwd
/users/vlad
$ ssh vlad@moon
Password:
![Page 9: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/9.jpg)
Unix Shell Secure Shell
$ pwd
/users/vlad
$ ssh vlad@moon
Password: ***
Access denied
Password:
![Page 10: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/10.jpg)
Unix Shell Secure Shell
$ pwd
/users/vlad
$ ssh vlad@moon
Password: ***
Access denied
Password: ********
moon> pwd
/home/vlad
moon> ls -F
bin/ cheese.txt dark_side/ rocks.cfg
![Page 11: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/11.jpg)
Unix Shell Secure Shell
$ pwd
/users/vlad
$ ssh vlad@moon
Password: ***
Access denied
Password: ********
moon> pwd
/home/vlad
moon> ls -F
bin/ cheese.txt dark_side/ rocks.cfg
moon> exit
$ pwd
/users/vlad
![Page 12: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/12.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon
Password: ********
moon> pwd
/home/vlad
moon> ls -F
bin/ cheese.txt dark_side/ rocks.cfg
moon> exit
$ pwd
/users/vlad
$ ls -F
bin/ data/ mail/ music/
notes.txt papers/ pizza.cfg solar/
solar.pdf swc/
![Page 13: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/13.jpg)
Unix Shell Secure Shell
$ scp vlad@moon:/home/vlad/cheese.txt
vlad@earth:/users/vlad
source file...
![Page 14: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/14.jpg)
Unix Shell Secure Shell
$ scp vlad@moon:/home/vlad/cheese.txt
vlad@earth:/users/vlad
source file...
…to destination directory
![Page 15: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/15.jpg)
Unix Shell Secure Shell
$ scp vlad@moon:/home/vlad/cheese.txt
vlad@earth:/users/vlad
source file...
…to destination directory
source and destination are written as
user@computer:path
![Page 16: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/16.jpg)
Unix Shell Secure Shell
$ scp vlad@moon:/home/vlad/cheese.txt
vlad@earth:/users/vlad
Password: ********
cheese.txt 100% 9 1.0 KB/s 00:00
![Page 17: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/17.jpg)
Unix Shell Secure Shell
$ scp vlad@moon:/home/vlad/cheese.txt
vlad@earth:/users/vlad
$ scp -r vlad@moon:/home/vlad/dark_side
vlad@earth:/users/vlad
-r indicates a directory and its contents
![Page 18: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/18.jpg)
Unix Shell Secure Shell
$ scp -r vlad@moon:/home/vlad/dark_side
vlad@earth:/users/vlad
$ scp -r vlad@moon:/home/vlad/dark_side
/users/vlad
$ pwd
/users/vlad
$ scp -r vlad@moon:/home/vlad/dark_side
.
same destination path
![Page 19: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/19.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon
Password: ********
moon> df –h
Filesystem Size Used Avail Use% Mounted On
/dev/sda1 7.9G 2.1G 5.5G 28% /
/dev/sda2 791G 150G 642G 19% /home
moon> df –h > usage.txt
moon> exit
$ scp vlad@moon:/home/vlad/usage.txt .
Password: ********
usage.txt 100% 134 1.0 KB/s 00:00
![Page 20: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/20.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon 'df –h'
Password: ********
Filesystem Size Used Avail Use% Mounted On
/dev/sda1 7.9G 2.1G 5.5G 28% /
/dev/sda2 791G 150G 642G 19% /home
![Page 21: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/21.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon 'df –h'
Password: ********
Filesystem Size Used Avail Use% Mounted On
/dev/sda1 7.9G 2.1G 5.5G 28% /
/dev/sda2 791G 150G 642G 19% /home
$ ssh vlad@moon 'df –h' >> usage.log
Password: ********
$ ls -F
bin/ data/ mail/ music/
notes.txt papers/ pizza.cfg solar/
solar.pdf swc/ usage.log usage.txt
same result
![Page 22: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/22.jpg)
Unix Shell Secure Shell
$ echo "open sesame, please" | ssh
vlad@moon 'cat > magic.txt'
Password: ********
character stream
![Page 23: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/23.jpg)
Unix Shell Secure Shell
$ echo "open sesame, please" | ssh
vlad@moon 'cat > magic.txt'
Password: ********
character streamremote shell receives
stream from pipe
remote command receives
input piped to ssh
cat repeats input stream
as output
redirection within
remote shell
![Page 24: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/24.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon 'ls –F /home/vlad'
Password: ********
bin/ cheese.txt dark_side/ rocks.cfg
$ echo "open sesame, please" | ssh
vlad@moon 'cat > magic.txt'
Password: ********
$ ssh vlad@moon 'ls –F /home/vlad'
Password: ********
bin/ cheese.txt dark_side/ magic.txt
rocks.cfg
before
after
![Page 25: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/25.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon 'ls –F /home/vlad'
Password: ********
bin/ cheese.txt dark_side/ rocks.cfg
$ echo "open sesame, please" | ssh
vlad@moon 'cat > magic.txt'
Password: ********
$ ssh vlad@moon 'ls –F /home/vlad'
Password: ********
bin/ cheese.txt dark_side/ magic.txt
rocks.cfg
$ scp vlad@moon:/home/vlad/magic.txt .
Password: ********
before
after
![Page 26: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/26.jpg)
Unix Shell Secure Shell
login as: vlad
Password: ********
shell
remote shell
![Page 27: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/27.jpg)
Unix Shell Secure Shell
shell
remote shell
login as: vlad
Password: thriller
![Page 28: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/28.jpg)
Unix Shell Secure Shell
shell
remote shell
login as: vlad
Password: thriller
![Page 29: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/29.jpg)
Unix Shell Secure Shell
shell
remote shell
![Page 30: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/30.jpg)
Unix Shell Secure Shell
shell
remote shell
![Page 31: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/31.jpg)
Unix Shell Secure Shell
shell
remote shell
![Page 32: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/32.jpg)
Unix Shell Secure Shell
shell
remote shell
![Page 33: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/33.jpg)
Unix Shell Secure Shell
shell
remote shell
![Page 34: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/34.jpg)
Unix Shell Secure Shell
shell
remote shell
public key
private key
(only 1 copy)encryption using
public key
cannot decrypt
using public key
![Page 35: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/35.jpg)
Unix Shell Secure Shell
shell
remote shell
login as: vlad
Password: *********
huxyo ew: xdvw
uqfcmjbn: lhiujdbj
![Page 36: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/36.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon
The authenticity of host ‘moon (10.1.2.3)‘
can't be established.
RSA key fingerprint is
f1:68:f5:90:47:dc:a8:e9:62:df:c9:21:f0:8b:c5:39.
Are you sure you want to continue connecting
(yes/no)? yes
Warning: Permanently added ‘moon,10.1.2.3' (RSA)
to the list of known hosts.
Password: ********
moon>
![Page 37: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/37.jpg)
Unix Shell Secure Shell
while true:
...
if time.mins == 30:
ssh vlad@moon 'df –h' >> usage.log
...
![Page 38: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/38.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon 'df –h' >> usage.log
Password:
Connection closed by 10.1.2.3
$
waited too long
while true:
...
if time.mins == 30:
ssh vlad@moon 'df –h' >> usage.log
...
![Page 39: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/39.jpg)
Unix Shell Secure Shell
host key pair
only 1 copy
default if user has no user key pair
user key pair 1
user key pair 2
![Page 40: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/40.jpg)
Unix Shell Secure Shell
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key
(/users/vlad/.ssh/id_rsa):
Enter passphrase (empty for no
passphrase): ********
Enter same passphrase again: ********
Your identification has been saved in
/users/vlad/.ssh/id_rsa.
Your public key has been saved in
/users/vlad/.ssh/id_rsa.pub.
The key fingerprint is:
d3:1a:27:38:aa:54:e8:a5:03:db:79:2f:b2:c3:c9:3d
press enter
![Page 41: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/41.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon
Enter passphrase for key
'/users/vlad/.ssh/id_rsa': ********
moon>
![Page 42: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/42.jpg)
Unix Shell Secure Shell
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key
(/users/vlad/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in
/users/vlad/.ssh/id_rsa.
Your public key has been saved in
/users/vlad/.ssh/id_rsa.pub.
The key fingerprint is:
d3:1a:27:38:aa:54:e8:a5:03:db:79:2f:b2:c3:c9:3d
press enter
![Page 43: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/43.jpg)
Unix Shell Secure Shell
$ scp ~/.ssh/id_rsa.pub vlad@moon
Password: ********
$ ssh vlad@moon
Password: ********
moon> cat id_rsa.pub >> ~/.ssh/authorized_keys
moon> exit
$ cat ~/.ssh/id_rsa.pub | ssh vlad@moon
'cat >> ~/.ssh/authorized_keys'
Password: ********
$ ssh-copy-id vlad@moon
Password: ********
![Page 44: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/44.jpg)
Unix Shell Secure Shell
$ ssh vlad@moon
moon>
while true:
...
if time.mins == 30:
ssh vlad@moon 'df –h' >> usage.log
...
![Page 45: The Secure Shell Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See](https://reader030.vdocument.in/reader030/viewer/2022032805/56649ef55503460f94c08b72/html5/thumbnails/45.jpg)
February 2011
created by
Elango Cheran
Copyright © Software Carpentry 2011
This work is licensed under the Creative Commons Attribution License
See http://software-carpentry.org/license.html for more information.