Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. thufir@mordor:~$
  2. thufir@mordor:~$ ssh-keygen -t rsa -b 768 -f ~/.ssh/gcloud -C thufir
  3. Generating public/private rsa key pair.
  4. Created directory '/home/thufir/.ssh'.
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in /home/thufir/.ssh/gcloud.
  8. Your public key has been saved in /home/thufir/.ssh/gcloud.pub.
  9. The key fingerprint is:
  10. SHA256:3paYqopihdHBHzW8F9zT+yMaB/JHn6LiMAtvJbW3YPI thufir
  11. The key's randomart image is:
  12. +----[RSA 768]----+
  13. | . oo. . . |
  14. | o . ..o o . |
  15. | . o . . . . . |
  16. | . . . . + . o |
  17. | o S + o o .|
  18. | . . + O = = = |
  19. | . . oX * B o .|
  20. |.o oo+E + |
  21. |+ ....oo... |
  22. +----[SHA256]-----+
  23. thufir@mordor:~$
  24. thufir@mordor:~$ nano .ssh/gcloud.pub
  25. thufir@mordor:~$
  26. thufir@mordor:~$ chmod 400 .ssh/gcloud.pub
  27. thufir@mordor:~$
  28. thufir@mordor:~$ cat .ssh/gcloud.pub
  29. thufir:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAYQDLehQya4f/rKixCbh2EIB0XvTocDlZnXds+xogHmYW6naXf/9+Uo27rnrnG9P69mQPCR85s9ZC+SfiuEUJ3CVn3XFrCr6wB3TBcjobRYgI62aQgCwyYx0Osc1yJfmxqRU= thufir google-ssh {"userName":"thufir","expireOn":"2018-12-04T20:12:00+0000"}
  30. thufir@mordor:~$
  31. thufir@mordor:~$ ssh-keygen -f .ssh/gcloud -y
  32. Enter passphrase:
  33. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAYQDLehQya4f/rKixCbh2EIB0XvTocDlZnXds+xogHmYW6naXf/9+Uo27rnrnG9P69mQPCR85s9ZC+SfiuEUJ3CVn3XFrCr6wB3TBcjobRYgI62aQgCwyYx0Osc1yJfmxqRU=
  34. thufir@mordor:~$
  35. thufir@mordor:~$ gcloud compute instances list
  36. Listed 0 items.
  37. thufir@mordor:~$
  38. thufir@mordor:~$ gcloud compute instances create <instance_name>
  39. Created [https://www.googleapis.com/compute/v1/projects/<project>/zones/<zone>/instances/<instance_name>].
  40. NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
  41. <instance_name> <zone> n1-standard-1 <internal_ip> <external_ip> RUNNING
  42. thufir@mordor:~$
  43. thufir@mordor:~$
  44. thufir@mordor:~$ gcloud compute instances add-metadata <instance_name> --metadata-from-file ssh-keys=.ssh/gcloud.pub
  45. Updated [https://www.googleapis.com/compute/v1/projects/<project>/zones/<zone>/instances/<instance_name>].
  46. thufir@mordor:~$
  47. thufir@mordor:~$ nano .ssh/config
  48. thufir@mordor:~$
  49. thufir@mordor:~$ cat .ssh/config
  50. Host gcloud
  51. HostName <external_ip>
  52. IdentityFile /home/thufir/.ssh/gcloud.pub
  53. User thufir
  54. thufir@mordor:~$
  55. thufir@mordor:~$ ll .ssh
  56. total 80
  57. drwx------ 2 thufir thufir 4096 Jul 29 02:42 ./
  58. drwx------ 71 thufir thufir 36864 Jul 29 02:33 ../
  59. -rw-rw-r-- 1 thufir thufir 96 Jul 29 02:42 config
  60. -rw------- 1 thufir thufir 791 Jul 29 02:33 gcloud
  61. -r-------- 1 thufir thufir 255 Jul 29 02:34 gcloud.pub
  62. thufir@mordor:~$
  63. thufir@mordor:~$ ssh gcloud
  64. The authenticity of host '<external_ip> (<external_ip>)' can't be established.
  65. ECDSA key fingerprint is SHA256:ek2g0GTj6Dxtb4vvwTNXRJgRKXnaLjoWZRv1lZ4pJ30.
  66. Are you sure you want to continue connecting (yes/no)? yes
  67. Warning: Permanently added '<external_ip>' (ECDSA) to the list of known hosts.
  68. Enter passphrase for key '/home/thufir/.ssh/gcloud.pub':
  69. Enter passphrase for key '/home/thufir/.ssh/gcloud.pub':
  70. Enter passphrase for key '/home/thufir/.ssh/gcloud.pub':
  71. Permission denied (publickey).
  72. thufir@mordor:~$
  73. thufir@mordor:~$ ssh-keygen -f .ssh/gcloud -y
  74. Enter passphrase:
  75. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAYQDLehQya4f/rKixCbh2EIB0XvTocDlZnXds+xogHmYW6naXf/9+Uo27rnrnG9P69mQPCR85s9ZC+SfiuEUJ3CVn3XFrCr6wB3TBcjobRYgI62aQgCwyYx0Osc1yJfmxqRU=
  76. thufir@mordor:~$
  77. thufir@mordor:~$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement