16. SSH Keys and Building Code#

Warning

This is not filled in yet. Use a previous semester until then

f22 build

ssh -l brownsarahm seawulf.uri.edu
brownsarahm@seawulf.uri.edu's password: 
Last login: Tue Oct 31 13:41:16 2023 from 172.20.131.240
[brownsarahm@seawulf ~]$ logout
Connection to seawulf.uri.edu closed.
ssh-keygen -f ~/seawulf -t rsa -b 1024
Generating public/private rsa key pair.
/Users/brownsarahm/seawulf already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/brownsarahm/seawulf.
Your public key has been saved in /Users/brownsarahm/seawulf.pub.
The key fingerprint is:
SHA256:/jDn06CDu24klK2z4dw6acHJuzax9685qHLaGeooX9g brownsarahm@240.131.20.172.s.wireless.uri.edu
The key's randomart image is:
+---[RSA 1024]----+
|                 |
|                 |
|     o           |
|    o .          |
|   + o  S        |
|   o@ ..  .      |
|  .oE& o+..o     |
|...+&o* +B. .    |
|oo=**X+++=+.     |

it asks you for an optional password to lock the key itself.

ssh-copy-id -i ~/seawulf brownsarahm@seawulf.uri.edu
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/brownsarahm/seawulf.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
brownsarahm@seawulf.uri.edu's password: 

Number of key(s) added:        1

Now try logging into the machine, with:   "ssh 'brownsarahm@seawulf.uri.edu'"
and check to make sure that only the key(s) you wanted were added.
cd

ls -a
.					.viminfo
..					.virtual_documents
.CFUserTextEncoding			.vscode
.DS_Store				.xonshrc
.Rhistory				.zsh_history
.Trash					.zsh_sessions
.anaconda				.zshrc
.anaconda_backup			2023-01-24.md
.atom					Applications
.bash_history				Creative Cloud Files
.bash_profile				Desktop
.bash_profile.pysave			DigiCertHighAssuranceEVRootCA.crt
.bash_sessions				Documents
.bundle					Downloads
.cache					Dropbox
.conda					Library
.condarc				Movies
.config					Music
.continuum				Pictures
.cups					Public
.dropbox				PycharmProjects
.gem					Untitled.ipynb
.gitconfig				Untitled1.ipynb
.ipynb_checkpoints			Untitled2.ipynb
.ipython				Untitled3.ipynb
.jupyter				Untitled4.ipynb
.keras					Zotero
.local					anaconda3
.matplotlib				bash_profile.backup2023-09-06
.mono					ca-bundle.crt
.npm					configs
.python_history				demo.ipynb
.r					scikit_learn_data
.rbenv					seaborn-data
.ssh					seawulf
.tcshrc					seawulf.pub
ls .ssh
config		known_hosts	seawulf		seawulf.pub
cd Documents/inclass/systems/

ssh -i ~/.ssh/seawulf brownsarah@seawulf.uri.edu
brownsarah@seawulf.uri.edu's password: 
ssh -i ~/seawulf brownsarah@seawulf.uri.edu
brownsarah@seawulf.uri.edu's password: 
Permission denied, please try again.
brownsarah@seawulf.uri.edu's password: 
Permission denied, please try again.
brownsarah@seawulf.uri.edu's password: 
brownsarah@seawulf.uri.edu: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
ls ~ |grep seawful

ls ~ |grep seawulf
seawulf
seawulf.pub
ssh -i ~/seawulf brownsarahm@seawulf.uri.edu
Last login: Thu Nov  2 12:36:20 2023 from 172.20.131.240
[brownsarahm@seawulf ~]$ interactive
salloc: Granted job allocation 27157
salloc: Waiting for resource configuration
salloc: Nodes n005 are ready for job
[brownsarahm@n005 ~]$ hostname
n005.cluster.com
[brownsarahm@n005 ~]$ mkdir compilec
mkdir: cannot create directory ‘compilec’: File exists
[brownsarahm@n005 ~]$ rm -rf compilec/
[brownsarahm@n005 ~]$ mkdir compilec
[brownsarahm@n005 ~]$ cd compilec/
[brownsarahm@n005 compilec]$ ls
[brownsarahm@n005 compilec]$ nano hello.c
[brownsarahm@n005 compilec]$ cat hello.c 
#include <stdio.h>
void main () {

 printf("Hello world\n");

}
[brownsarahm@n005 compilec]$ ls
hello.c
[brownsarahm@n005 compilec]$ gcc -E hello.c -o hello.i
[brownsarahm@n005 compilec]$ ls
hello.c  hello.i
[brownsarahm@n005 compilec]$ cat hello.i |head
# 1 "hello.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "hello.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 27 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 375 "/usr/include/features.h" 3 4
[brownsarahm@n005 compilec]$ cat hello.i |tail

extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
# 943 "/usr/include/stdio.h" 3 4

# 2 "hello.c" 2
void main () {

 printf("Hello world\n");

}
[brownsarahm@n005 compilec]$ cat hello.i | wc-l
bash: wc-l: command not found
[brownsarahm@n005 compilec]$ cat hello.i | wc -l
842
[brownsarahm@n005 compilec]$ cat hello.c | wc -l
6
[brownsarahm@n005 compilec]$ gcc -S hello.i
[brownsarahm@n005 compilec]$ ls
hello.c  hello.i  hello.s
[brownsarahm@n005 compilec]$ cat hello.s
	.file	"hello.c"
	.section	.rodata
.LC0:
	.string	"Hello world"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$.LC0, %edi
	call	puts
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)"
	.section	.note.GNU-stack,"",@progbits
[brownsarahm@n005 compilec]$ gcc -c hello.s -o hello.o
[brownsarahm@n005 compilec]$ ls
hello.c  hello.i  hello.o  hello.s
[brownsarahm@n005 compilec]$ cat hello.o
ELF>?@@
UH???]?Hello worldGCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)zRx
K                                                               A?C
??      hello.cmainputs


???????? .symtab.strtab.shstrtab.rela.text.data.bss.rodata.comment.note.GNU-stack.rela.eh_frame @?0
&PP1P
     90\.B?W?R@
?
	?0a[brownsarahm@n005 compilec]$ gcc -o hello hello.o -lm
[brownsarahm@n005 compilec]$ ls
hello  hello.c  hello.i  hello.o  hello.s
[brownsarahm@n005 compilec]$ ./hello 
Hello world
[brownsarahm@n005 compilec]$ history
    1  ls -hw
    2  lshw
    3  exit
    4  ls
    5  pwd
    6  whoami
    7  wget http://www.hpc-carpentry.org/hpc-shell/files/bash-lesson.tar.gz
    8  ls
    9  tar -xvf bash-lesson.tar.gz 
   10  ls
   11  cat dmel-all-r6.19.gtf 
   12  head dmel-all-r6.19.gtf 
   13  tail dmel-all-r6.19.gtf 
   14  wc -l dmel-all-r6.19.gtf 
   15  ls
   16  wc -l *.fastw
   17  wc -l *.fastq
   18  wc -l *.fastq > linecounts.txt
   19  cat linecounts.txt 
   20  grep Act5c dmel-all-r6.19.gtf 
   21  head dmel-all-r6.19.gtf 
   22  grep mRNA dmel-all-r6.19.gtf 
   23  grep mRNA dmel-all-r6.19.gtf | wc -l
   24  echo "echo 'script works'" >> demo.sh
   25  cat demo.sh 
   26  ./demo.sh
   27  ls -l
   28  mkdir results
   29  ls -l
   30  pwd
   31  ls /home/brownsarahm
   32  cat /home/brownsarahm/demo.sh
   33  bash demo.sh 
   34  ./ demo.sh 
   35  ./demo.sh 
   36  chmod +x demo.sh 
   37  ls -l
   38  ./demo.sh 
   39  nano demo.sh
   40  cat demo.sh 
   41  ls -l
   42  nano my_job.sh
   43  sbatch my_job.sh 
   44  squeue --job 23950
   45  interactive
   46  wall "hello"
   47  exit 
   48  ls
   49  exit
   50  cat ~/.ssh/authorized_keys 
   51  rm ~/.ssh/authorized_keys 
   52  exit
   53  ls -a
   54  ls -al
   55  exit
   56  cat /var/log/auth.log
   57  exit
   58  ls
   59  ls .ssh/
   60  rm .ssh/
   61  ls
   62  rm .ssh/authorized_keys 
   63  ls
   64  exit
   65  cat .ssh/authorized_keys 
   66  exit
   67  ls .ssh/
   68  cat .ssh/authorized_keys 
   69  cat /var/log/auth.log
   70  exit
   71  ls
   72  pwd
   73  whoami
   74  wget http://www.hpc-carpentry.org/hpc-shell/files/bash-lesson.tar.gz
   75  ls
   76  rm *.fastq
   77  tar -xvf bash-lesson.tar.gz 
   78  cat SRR307023_1.fastq 
   79  head SRR307023_1.fastq 
   80  tail SRR307023_1.fastq 
   81  wc -l SRR307023_1.fastq 
   82  wc -l *.fastq 
   83  wc -l dmel-all-r6.19.gtf 
   84  grep Act5c dmel-all-r6.19.gtf 
   85  grep mRNA dmel-all-r6.19.gtf 
   86  echo "echo 'script works'" >> demo.sh
   87  cat demo.sh 
   88  echo "echo 'script works'" > demo.sh
   89  cat demo.sh 
   90  ./demo.sh 
   91  ls -l
   92  chmod +x demo.sh 
   93  ls -l
   94  ./demo.sh 
   95  exit
   96  lshw
   97  exit
   98  interactive
   99  grep Act5C dmel-all-r6.19.gtf 
  100  grep Act5C dmel-all-r6.19.gtf | wc -l
  101  grep Act5C dmel-all-r6.19.gtf | head -n 1
  102  exit
  103  pwd
  104  ls
  105  mkdir example
  106  cd example/
  107  pwd
  108  mkdir ex2
  109  cd ex2/
  110  pwd
  111  cd 
  112  ls -l
  113  ls -l --block-size=M
  114  exit
  115  ls
  116  ls -a
  117  ls .ssh/
  118  ls .ssh/authorized_keys 
  119  ls
  120  ls .ssh/authorized_keys 
  121  ls .ssh/authorized_keys
  122  exit
  123  ls
  124  lshw 
  125  cat demo.sh 
  126  ./demo.sh 
  127  ls my_job.sh 
  128  cat my_job.sh 
  129  exit
  130  python3
  131  exit
  132  pwd
  133  lshw
  134  interactive
  135  interactive -t 0:03:00
  136  interactive -c 4 
  137  interactive
  138  exit
  139  gcc
  140  clear
  141  exit
  142  mkdir compilec
  143  cd compilec/
  144  ls
  145  nano hello.c
  146  cat hello.c 
  147  ls
  148  nano hello.c
  149  gcc -E hello.c -o hello.i
  150  ls
  151  cat hello.i | head 
  152  cat hello.c
  153  cat hello.i | tail 
  154  cat hello.i | wc -l
  155  cat hello.c | wc -l
  156  gcc -S hello.i
  157  ls
  158  cat hello.s
  159  cat hello.c
  160  gcc -c hello.s -o hello.o
  161  ls
  162  cat hello.o
  163  gcc -o hello hello.o -lm 
  164  ls
  165  ./hello 
  166  ls -la
  167  ls
  168  rm hello.i hello.s hello.o hello
  169  ls
  170  gcc --help
  171  gcc -Wall -g -o hello hello.c -lm
  172  ls
  173  nano main.c
  174  nano help.c
  175  cat main.c 
  176  cat help.c
  177  gcc -Wall -g -c main.c 
  178  nano main.c
  179  cat main.
  180  cat main.c
  181  gcc -Wall -g -c main.c 
  182  gcc -Wall -g -c help.c
  183  ls
  184  gcc -o demo main.o help.o -lm
  185  ls
  186  ./demo 
  187  ./demo 6
  188  exit
  189  interactive
  190  exit
  191  ls
  192  wget http://www.hpc-carpentry.org/hpc-shell/files/bash-lesson.tar.gz
  193  ls
  194  man tar
  195  tar -xvf bash-lesson.tar.gz 
  196  cat dmel-all-r6.19.gtf 
  197  head dmel-all-r6.19.gtf 
  198  man head
  199  head dmel-all-r6.19.gtf -n 5
  200  tail dmel-all-r6.19.gtf -n 5
  201  wc dmel-all-r6.19.gtf 
  202  man wc
  203  wc -l dmel-all-r6.19.gtf 
  204  ls
  205  wc -l *.fastq
  206  wc -l *.fastq > linecounts.txt
  207  cat linecounts.txt 
  208  grep Act5c dmel-all-r6.19.gtf 
  209  grep mRNA  dmel-all-r6.19.gtf 
  210  grep mRNA  dmel-all-r6.19.gtf |wc -l
  211  exit
  212  pwd
  213  ls
  214  rm *
  215  ls
  216  whoami
  217  interactive
  218  exit
  219  nano example-job.sh
  220  cat example-job.sh 
  221  man echo
  222  bash example-job.sh 
  223  ./example-job.sh
  224  ls -l
  225  chmod +x example-job.sh 
  226  ls -l | grep example
  227  ./example-job.sh
  228  cp example-job.sh ex2.sh
  229  cp example-job.sh ex3.sh
  230  cp example-job.sh ex4.sh
  231  ls| grep ex
  232  ls -l
  233  chmod -x ex*.sh
  234  ls -l | grep ex
  235  ./example-job.sh
  236  chmod +x example-job.sh 
  237  ./example-job.sh
  238  nano example-job.sh 
  239  cat example-job.sh 
  240  sbatch example-job.sh 
  241  squeue -u brownsarahm
  242  sbatch example-job.sh 
  243  squeue -u brownsarahm
  244  whoami
  245  ls 
  246  cat slurm-27093.out 
  247  cat slurm-27107.out 
  248  nano example-job.sh 
  249  logout
  250  cat ex2.sh 
  251  chmod +x ex2.sh 
  252  sbatch -J hello -o name-%j ex2.sh
  253  nano ex2.sh 
  254  sbatch -J hello -o name-%j ex2.sh
  255  ls |grap name
  256  ls |grep name
  257  sbatch  ex2.sh
  258  sysapprovedbages
  259  sysapprovedbadges --help
  260  exit
  261  logout
  262  hostname
  263  mkdir compilec
  264  rm -rf compilec/
  265  mkdir compilec
  266  cd compilec/
  267  ls
  268  nano hello.c
  269  cat hello.c 
  270  ls
  271  gcc -E hello.c -o hello.i
  272  ls
  273  cat hello.i |head
  274  cat hello.i |tail
  275  cat hello.i | wc-l
  276  cat hello.i | wc -l
  277  cat hello.c | wc -l
  278  gcc -S hello.i
  279  ls
  280  cat hello.s
  281  gcc -c hello.s -o hello.o
  282  ls
  283  cat hello.o
  284  gcc -o hello hello.o -lm
  285  ls
  286  ./hello 
  287  history
[brownsarahm@n005 compilec]$ ls -l
total 44
-rwxr-xr-x 1 brownsarahm spring2022-csc392  8360 Nov  2 13:27 hello
-rw-r--r-- 1 brownsarahm spring2022-csc392    64 Nov  2 13:12 hello.c
-rw-r--r-- 1 brownsarahm spring2022-csc392 16865 Nov  2 13:14 hello.i
-rw-r--r-- 1 brownsarahm spring2022-csc392  1496 Nov  2 13:23 hello.o
-rw-r--r-- 1 brownsarahm spring2022-csc392   433 Nov  2 13:19 hello.s
[brownsarahm@n005 compilec]$ ls -la
total 48
drwxr-xr-x 2 brownsarahm spring2022-csc392    98 Nov  2 13:27 .
drwx------ 7 brownsarahm spring2022-csc392  4096 Nov  2 13:11 ..
-rwxr-xr-x 1 brownsarahm spring2022-csc392  8360 Nov  2 13:27 hello
-rw-r--r-- 1 brownsarahm spring2022-csc392    64 Nov  2 13:12 hello.c
-rw-r--r-- 1 brownsarahm spring2022-csc392 16865 Nov  2 13:14 hello.i
-rw-r--r-- 1 brownsarahm spring2022-csc392  1496 Nov  2 13:23 hello.o
-rw-r--r-- 1 brownsarahm spring2022-csc392   433 Nov  2 13:19 hello.s
[brownsarahm@n005 compilec]$ nano hello.c
[brownsarahm@n005 compilec]$ cat hello.
cat: hello.: No such file or directory
[brownsarahm@n005 compilec]$ cat hello.c
#include <stdio.h>
void main () {

 printf("Hello world!\n");

}
[brownsarahm@n005 compilec]$ ./hello 
Hello world
[brownsarahm@n005 compilec]$ gcc hello.c
[brownsarahm@n005 compilec]$ ./hello 
Hello world
[brownsarahm@n005 compilec]$ gcc hello.c -lm
[brownsarahm@n005 compilec]$ ./hello 
Hello world
[brownsarahm@n005 compilec]$ ls
a.out  hello  hello.c  hello.i  hello.o  hello.s
[brownsarahm@n005 compilec]$ ./a.out 
Hello world!
[brownsarahm@n005 compilec]$ gcc hello.c -o hello2
[brownsarahm@n005 compilec]$ ./hello2
Hello world!
[brownsarahm@n005 compilec]$ gcc hello.c
[brownsarahm@n005 compilec]$ ls
a.out  hello  hello2  hello.c  hello.i  hello.o  hello.s
[brownsarahm@n005 compilec]$ nano hello.c
[brownsarahm@n005 compilec]$ gcc hello.c
[brownsarahm@n005 compilec]$ ls
a.out  hello  hello2  hello.c  hello.i  hello.o  hello.s
[brownsarahm@n005 compilec]$ ./a.out 
Hello world! again
[brownsarahm@n005 compilec]$ cat hello.c
#include <stdio.h>
void main () {

 printf("Hello world! again\n");

}
[brownsarahm@n005 compilec]$ 

16.1. Prepare for Next Class#

No separate preparation, focus on badge work and reviewing the notes if you missed class.

Make sure you did the prep for 10-31, we will work from that on 11/2.

16.2. Review today’s class#

  1. create a new ssh key and configure it to your GitHub account

  2. Practice using gcc. Repeat steps we did in class, change the order of parameters; try skipping steps to produce errors, etc. Then in gcctips.md summarize what you learned as a list of tips and reminders on what the parameters do/why/when you would need them (or not). (to reinforce what we learned)

16.3. More Practice#

  1. create a new ssh key and configure it to your GitHub account

  2. Install gcc locally and practice using it. Repeat steps we did in class on your computer and then change the order of parameters; try skipping steps to produce errors, etc. Export the list of variations you tried and summarize what you learned as a list of tips and reminders on what the parameters do/why/when you would need them (or not) in gcctips.md. (to reinforce what we learned)

  3. Write two short programs that do the same thing in different ways and compile them both to assembly (eg using a for vs while loop to sum numbers up to a number). Check the assembly to see if they produce the same thing or if it’s different. Save your code (in code blocks) and notes about your findings in assemblycompare.md

16.4. Experience Report Evidence#

16.5. Questions After Today’s Class#

16.5.1. What else can we create ssh keys for?#

You can use them for GitHub and most developer tools that have authentication provide this option.

16.5.2. Why did we need a .i, .s, .o files?#

When you build your code, your tools often go from source code to executable without saving the file at the intermediate points. We went through and stopped it at the same

16.5.3. How often are SSH keys used by a developer?#

I cannot give a speific number, but they are used for remote systems and can be used for GitHub.

16.5.4. Why did we not need to do the intermediate steps when we changed the program?#

We did not need to stop at the intermediate points the first time, we stopped it after each step to look at it, so that we could learn about all of the steps.

We alwasy have the option to do the whole process at once.

16.5.5. can you use/import other libraies into seawulf and use them in a program made in seawulf?#

Yes. To an extent, there are limits to what you can install, but the basic ones are typically here.

You can see what is there with module available

16.5.6. When compiling using the following line: gcc hello.c -o hello does this remove the .o .s and .i file because it just created the executable file hello?#

It does not remove them, but it does skip writing the file out at those intermediate points.

16.5.7. Are the public and private keys the primes themselves, or are they something derived from the primes?#

The product of the primes is part of the public key along with an exponent integer. The two primes are also used to compute the private key. The primes themselves need to be private, but are actually not needed to be know, so they are generally discarded.

16.5.8. What are the main uses of doing this?#

Understanding the steps of building can help you debug.

16.5.9. Will this ever be seen as a better alternative to write code as opposed?#

Sometimes the terminal is the fastest tool you have available, like today.