The Unix Shell The Secure Shell Copyright Software

  • Slides: 45
Download presentation
The Unix Shell The Secure Shell Copyright © Software Carpentry 2011 This work is

The Unix Shell 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.

$ pwd shell Unix Shell Secure Shell

$ pwd shell Unix Shell Secure Shell

$ pwd /users/vlad $ shell Unix Shell Secure Shell

$ pwd /users/vlad $ shell Unix Shell Secure Shell

login as: vlad Password: **** shell Unix Shell Secure Shell

login as: vlad Password: **** shell Unix Shell Secure Shell

login as: vlad Password: **** $ shell Unix Shell Secure Shell

login as: vlad Password: **** $ shell Unix Shell Secure Shell

login as: vlad Password: **** moon> shell remote shell Unix Shell Secure Shell

login as: vlad Password: **** moon> shell remote shell Unix Shell Secure Shell

login as: vlad Password: **** moon> shell remote shell Unix Shell Secure Shell

login as: vlad Password: **** moon> shell remote shell Unix Shell Secure Shell

$ pwd /users/vlad $ ssh vlad@moon Password: Unix Shell Secure Shell

$ pwd /users/vlad $ ssh vlad@moon Password: Unix Shell Secure Shell

$ pwd /users/vlad $ ssh vlad@moon Password: *** Access denied Password: Unix Shell Secure

$ pwd /users/vlad $ ssh vlad@moon Password: *** Access denied Password: Unix Shell Secure Shell

$ pwd /users/vlad $ ssh vlad@moon Password: *** Access denied Password: **** moon> pwd

$ pwd /users/vlad $ ssh vlad@moon Password: *** Access denied Password: **** moon> pwd /home/vlad moon> ls -F bin/ cheese. txt Unix Shell dark_side/ rocks. cfg Secure Shell

$ pwd /users/vlad $ ssh vlad@moon Password: *** Access denied Password: **** moon> pwd

$ pwd /users/vlad $ ssh vlad@moon Password: *** Access denied Password: **** moon> pwd /home/vlad moon> ls -F bin/ cheese. txt moon> exit $ pwd /users/vlad Unix Shell dark_side/ rocks. cfg Secure Shell

$ ssh vlad@moon Password: **** moon> pwd /home/vlad moon> ls -F bin/ cheese. txt

$ ssh vlad@moon Password: **** moon> pwd /home/vlad moon> ls -F bin/ cheese. txt moon> exit $ pwd /users/vlad $ ls -F bin/ notes. txt solar. pdf Unix Shell data/ papers/ swc/ dark_side/ mail/ pizza. cfg rocks. cfg music/ solar/ Secure Shell

$ scp vlad@moon: /home/vlad/cheese. txt vlad@earth: /users/vlad source file. . . Unix Shell Secure

$ scp vlad@moon: /home/vlad/cheese. txt vlad@earth: /users/vlad source file. . . Unix Shell Secure Shell

$ scp vlad@moon: /home/vlad/cheese. txt vlad@earth: /users/vlad source file. . . …to destination directory

$ scp vlad@moon: /home/vlad/cheese. txt vlad@earth: /users/vlad source file. . . …to destination directory Unix Shell Secure Shell

$ scp vlad@moon: /home/vlad/cheese. txt vlad@earth: /users/vlad source file. . . …to destination directory

$ 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 Unix Shell Secure Shell

$ scp vlad@moon: /home/vlad/cheese. txt vlad@earth: /users/vlad Password: **** cheese. txt 100% 9 1.

$ scp vlad@moon: /home/vlad/cheese. txt vlad@earth: /users/vlad Password: **** cheese. txt 100% 9 1. 0 KB/s 00: 00 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

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

$ 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 Unix Shell Secure Shell

$ ssh vlad@moon Password: **** moon> df –h Filesystem Size Used /dev/sda 1 7.

$ ssh vlad@moon Password: **** moon> df –h Filesystem Size Used /dev/sda 1 7. 9 G 2. 1 G /dev/sda 2 791 G 150 G moon> df –h > usage. txt Avail 5. 5 G 642 G Use% Mounted On 28% / 19% /home moon> exit $ scp vlad@moon: /home/vlad/usage. txt. Password: **** usage. txt 100% 134 1. 0 KB/s 00: 00 Unix Shell Secure Shell

$ ssh vlad@moon 'df Password: **** Filesystem Size /dev/sda 1 7. 9 G /dev/sda

$ ssh vlad@moon 'df Password: **** Filesystem Size /dev/sda 1 7. 9 G /dev/sda 2 791 G Unix Shell –h' Used 2. 1 G 150 G Avail 5. 5 G 642 G Use% Mounted On 28% / 19% /home Secure Shell

$ ssh vlad@moon 'df Password: **** Filesystem Size /dev/sda 1 7. 9 G /dev/sda

$ ssh vlad@moon 'df Password: **** Filesystem Size /dev/sda 1 7. 9 G /dev/sda 2 791 G $ ssh vlad@moon 'df Password: **** $ ls -F bin/ notes. txt solar. pdf –h' data/ papers/ swc/ Used Avail Use% Mounted On 2. 1 G 5. 5 G 28% / 150 G 642 G 19% /home –h' >> usage. log mail/ pizza. cfg usage. log music/ solar/ usage. txt same result Unix Shell Secure Shell

character stream $ echo "open sesame, please" | vlad@moon 'cat > magic. txt' Password:

character stream $ echo "open sesame, please" | vlad@moon 'cat > magic. txt' Password: **** Unix Shell ssh Secure Shell

character stream $ echo "open sesame, please" | vlad@moon 'cat > magic. txt' Password:

character stream $ echo "open sesame, please" | vlad@moon 'cat > magic. txt' Password: **** remote command receives input piped to ssh cat repeats input stream as output Unix Shell remote shell receives stream from pipe ssh redirection within remote shell Secure Shell

before $ ssh vlad@moon 'ls –F /home/vlad' Password: **** bin/ cheese. txt dark_side/ rocks.

before $ 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: **** after $ ssh vlad@moon 'ls –F /home/vlad' Password: **** bin/ cheese. txt rocks. cfg Unix Shell dark_side/ magic. txt Secure Shell

before $ ssh vlad@moon 'ls –F /home/vlad' Password: **** bin/ cheese. txt dark_side/ rocks.

before $ 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: **** after $ 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: **** Unix Shell Secure Shell

login as: vlad Password: **** shell remote shell Unix Shell Secure Shell

login as: vlad Password: **** shell remote shell Unix Shell Secure Shell

login as: vlad Password: thriller shell remote shell Unix Shell Secure Shell

login as: vlad Password: thriller shell remote shell Unix Shell Secure Shell

login as: vlad Password: thriller shell remote shell Unix Shell Secure Shell

login as: vlad Password: thriller shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

shell remote shell Unix Shell Secure Shell

public key cannot decrypt using public key encryption using private key (only 1 copy)

public key cannot decrypt using public key encryption using private key (only 1 copy) public key shell remote shell Unix Shell Secure Shell

login as: vlad Password: ***** huxyo ew: xdvw uqfcmjbn: lhiujdbj shell remote shell Unix

login as: vlad Password: ***** huxyo ew: xdvw uqfcmjbn: lhiujdbj shell remote shell Unix Shell Secure Shell

$ ssh vlad@moon The authenticity of host ‘moon (10. 1. 2. 3)‘ can't be

$ ssh vlad@moon The authenticity of host ‘moon (10. 1. 2. 3)‘ can't be established. RSA key fingerprint is f 1: 68: f 5: 90: 47: dc: a 8: e 9: 62: df: c 9: 21: f 0: 8 b: c 5: 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> Unix Shell Secure Shell

while true: . . . if time. mins == 30: ssh vlad@moon 'df –h'

while true: . . . if time. mins == 30: ssh vlad@moon 'df –h' >> usage. log. . . Unix Shell Secure Shell

while true: . . . if time. mins == 30: ssh vlad@moon 'df –h'

while true: . . . if time. mins == 30: ssh vlad@moon 'df –h' >> usage. log. . . $ ssh vlad@moon 'df –h' >> usage. log Password: Connection closed by 10. 1. 2. 3 $ Unix Shell waited too long Secure Shell

user key pair 2 user key pair 1 Unix Shell host key pair only

user key pair 2 user key pair 1 Unix Shell host key pair only 1 copy default if user has no user key pair Secure Shell

$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to

$ 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: **** press enter 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: d 3: 1 a: 27: 38: aa: 54: e 8: a 5: 03: db: 79: 2 f: b 2: c 3: c 9: 3 d Unix Shell Secure Shell

$ ssh vlad@moon Enter passphrase for key '/users/vlad/. ssh/id_rsa': **** moon> Unix Shell Secure

$ ssh vlad@moon Enter passphrase for key '/users/vlad/. ssh/id_rsa': **** moon> Unix Shell Secure Shell

$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to

$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key press enter (/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: d 3: 1 a: 27: 38: aa: 54: e 8: a 5: 03: db: 79: 2 f: b 2: c 3: c 9: 3 d Unix Shell Secure Shell

$ scp ~/. ssh/id_rsa. pub vlad@moon Password: **** $ ssh vlad@moon Password: **** moon>

$ 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: **** Unix Shell Secure Shell

$ ssh vlad@moon> while true: . . . if time. mins == 30: ssh

$ ssh vlad@moon> while true: . . . if time. mins == 30: ssh vlad@moon 'df –h' >> usage. log. . . Unix Shell Secure Shell

created by Elango Cheran February 2011 Copyright © Software Carpentry 2011 This work is

created by Elango Cheran February 2011 Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See http: //software-carpentry. org/license. html for more information.