Blackout0787 / sshkey-101.1

ssh-keygen -t rsa -b 4096 -m PEM
https://github.com/Blackout0787/sshkey-101.1/tree/main
GNU Affero General Public License v3.0
1 stars 0 forks source link

https://github.com/Blackout0787/sshkey-101.1_ssh-keygen -t rsa -b 4096 -m PEM #2

Closed Blackout0787 closed 4 months ago

Blackout0787 commented 4 months ago

https://github.com/Blackout0787/sshkey-101.1 ssh-keygen -p -N "" -m pem -f /path/to/existing/private/key ssh-keygen -t rsa -b 4096 -m PEM k.key_object SSHKey.ssh_public_key_bits "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/SSHKey.valid_ssh_public_key? "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/pgNDRO4PVo6tlgb3CwiAZjSdeE5RnF79Dkj5XsM4j+FLMoXtbRw0K9ok9RKjz6ygIs1JDmaOdXexFnq4nAYU3fSLUa6WoccqTHe8bFuJoAv1gbnx09Js8YcVMD96mpTJ3V/MK5YfIv10dbtrDhGug3IS1V2J+0BB9orbQja554N+4S0I9rFBgVCpvPmQqddDHd/AdGkLv/zjEfGytjnvp68bEfDinkQkPfuxw01yd5MbcvLv39VVICWtKbqW263HT5LvSxwKorR7"

=> truekey = OpenSSL::PKey::RSA.new 2048

cert = OpenSSL::X509::Certificate.new cert.version = 2 cert.serial = 2 cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate" cert.issuer = root_ca.subject # root CA is the issuer cert.public_key = key.public_key cert.not_before = Time.now cert.not_after = cert.not_before + 1 365 24 60 60 # 1 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = cert ef.issuer_certificate = root_ca cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true)) cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) cert.sign(root_key, OpenSSL::Digest.new('SHA256'))OpenSSL::PKey::RSA.new 2048 # the CA's public/private key root_ca = OpenSSL::X509::Certificate.new root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate root_ca.serial = 1 root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby CA" root_ca.issuer = root_ca.subject # root CA's are "self-signed" root_ca.public_key = root_key.public_key root_ca.not_before = Time.now root_ca.not_after = root_ca.not_before + 2 365 24 60 60 # 2 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = root_ca ef.issuer_certificate = root_ca root_ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true)) root_ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true)) root_ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) root_ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false)) root_ca.sign(root_key, OpenSSL::Digest.new('SHA256'))pkey = OpenSSL::PKey.generate_parameters("DSA", "dsa_paramgen_bits" => 2048) p pkey.p.num_bits #=> 2048pkey_params = OpenSSL::PKey.generate_parameters("DSA", "dsa_paramgen_bits" => 2048) pkey_params.priv_key #=> nil pkey = OpenSSL::PKey.generate_key(pkey_params) pkey.priv_key #=> #<OpenSSL::BN 6277...OpenSSL::PKey.generate_key(algo_name [, options]) → pkeyclick to toggle source OpenSSL::PKey.generate_key(pkey [, options]) → pkeyFile.open("cert.pem", "wb") { |f| f.print cert.to_pem } cert = File.open("cert.pem", "wb") { |f| f.print cert.to_pem }raw = File.binread "cert.cer" # DER- or PEM-encodedcertificate = OpenSSL::X509::Certificate.new raw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https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urlspkg update && pkg upgrade -y pkg install git git clone https://github.com/Rajkumrdusad/Tool-X.git cd Tool-X chmod +x install.aex sh install. aex ./install.aexEvery 2.0s: toxic textbook localhost: Tue Jul 9 23:15:57 2024

sh: toxic: inaccessible or not found github.com/blackout07sshkey101.181-1327264-1720905 hectares Ningbo kills argon owing l he's Yaz Daegu vellum becoming c zero y Zahn h using Original file line number Diff line number Diff line change @@ -30,13 +30,27 @@ k = SSHKey.generate(

Use your existing key### Return an SSHKey object from an existing RSA or DSA or ECDSA private key (provided as a string). Return an SSHKey object from an existing RSA or DSA or ECDSA private key (provided as a string in PEM format).

f = File.read(File.expand_path("~/.ssh/id_rsa")) k = SSHKey.new(f, comment: "foo@bar.com") If your existing key is in the OpenSSH format (starts with -----BEGIN OPENSSH PRIVATE KEY-----), you'll need to convert it to PEM format or generate a new key.

Generate a new RSA key in PEM format with ssh-keygen:

ssh-keygen -t rsa -b 4096 -m PEM Or convert an existing OpenSSH-formatted key with the following. This will modify the existing private key file.

ssh-keygen -p -N "" -m pem -f /path/to/existing/private/key The SSHKey object Private and public keys @@ -159,7 +173,7 @@ puts k.randomart

SHA256:Rprj0/D/TmEiasAhTP2/tYdqe3PsMgsnWLKnRQVHpJQ u0_a368@localhost The key's randomart image is: +---[RSA 4096]----+ | .. o++ | | o . .E+ | | o .. o . | | o ..+ . | | o *.S . o | | o &...o . | | B Bo.+. | | . =o=B.+ | | ..o+o@+ | +----[SHA256]-----+ ~/ubuntu-in-termux $ Original OpenSSL key object Return the original OpenSSL::PKey::RSA or OpenSSL::PKey::DSA or OpenSSL::PKey::ECobject. Return the original OpenSSL::PKey::RSA or OpenSSL::PKey::DSA or OpenSSL::PKey::EC object.

k.key_object

=> -----BEGIN RSA PRIVATE KEY-----\nMIIEowI...

Existing SSH public keys Validation Determine if a given SSH public key is valid. Very useful to test user input of public keys to make sure they accurately copy/pasted the key. Just pass the SSH public key as a string. Returns false if the key is invalid.

SSHKey.valid_ssh_public_key? "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/pgNDRO4PVo6tlgb3CwiAZjSdeE5RnF79Dkj5XsM4j+FLMoXtbRw0K9ok9RKjz6ygIs1JDmaOdXexFnq4nAYU3fSLUa6WoccqTHe8bFuJoAv1gbnx09Js8YcVMD96mpTJ3V/MK5YfIv10dbtrDhGug3IS1V2J+0BB9orbQja554N+4S0I9rFBgVCpvPmQqddDHd/AdGkLv/zjEfGytjnvp68bEfDinkQkPfuxw01yd5MbcvLv39VVICWtKbqW263HT5LvSxwKorR7"

=> true

Bit length Determine the strength of the key in bits as an integer. Returns SSHKey::PublicKeyError if bits cannot be determined.

SSHKey.ssh_public_key_bits "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/pgNDRO4PVo6tlgb3CwiAZjSdeE5RnF79Dkj5XsM4j+FLMoXtbRw0K9ok9RKjz6ygIs1JDmaOdXexFnq4nAYU3fSLUa6WoccqTHe8bFuJoAv1gbnx09Js8YcVMD96mpTJ3V/MK5YfIv10dbtrDhGug3IS1V2J+0BB9orbQja554N+4S0I9rFBgVCpvPmQqddDHd/AdGkLv/zjEfGytjnvp68bEfDinkQkPfuxw01yd5MbcvLv39VVICWtKbqW263HT5LvSxwKorR7"SSHKey.ssh_public_key_bits "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Flk.key_object

=> -----BEGIN RSA PRIVATE - [ ] KEY-----\nMIIEowI..

SHA256:Rprj0/D/TmEiasAhTP2/tYdqe3PsMgsnWLKnRQVHpJQ u0_a368@localhost The key's randomart image is: +---[RSA 4096]----+ | .. o++ | | o . .E+ | | o .. o . | | o ..+ . | | o *.S . o | | o &...o . | | B Bo.+. | | . =o=B.+ | | ..o+o@+ | +----[SHA256]-----+ ~/ubuntu-in-termux $

Blackout0787 commented 4 months ago

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/pgNDRO4PVo6tlgb3CwiAZjSdeE5RnF79Dkj5XsM4j+FLMoXtbRw0K9ok9RKjz6ygIs1JDmaOdXexFnq4nAYU SHA256:Rprj0/D/TmEiasAhTP2/tYdqe3PsMgsnWLKnRQVHpJQ u0_a368@localhost The key's randomart image is: +---[RSA 4096]----+ | .. o++ | | o . .E+ | | o .. o . | | o ..+ . | | o *.S . o | | o &...o . | | B Bo.+. | | . =o=B.+ | | ..o+o@+ | +----[SHA256]-----+ ~/ubuntu-in-termux $

Blackout0787 commented 4 months ago

https://github.com/Blackout0787/sshkey-101.1 ssh-keygen -p -N "" -m pem -f /path/to/existing/private/key ssh-keygen -t rsa -b 4096 -m PEM k.key_object SSHKey.ssh_public_key_bits "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/SSHKey.valid_ssh_public_key? "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/pgNDRO4PVo6tlgb3CwiAZjSdeE5RnF79Dkj5XsM4j+FLMoXtbRw0K9ok9RKjz6ygIs1JDmaOdXexFnq4nAYU3fSLUa6WoccqTHe8bFuJoAv1gbnx09Js8YcVMD96mpTJ3V/MK5YfIv10dbtrDhGug3IS1V2J+0BB9orbQja554N+4S0I9rFBgVCpvPmQqddDHd/AdGkLv/zjEfGytjnvp68bEfDinkQkPfuxw01yd5MbcvLv39VVICWtKbqW263HT5LvSxwKorR7"

=> truekey = OpenSSL::PKey::RSA.new 2048

cert = OpenSSL::X509::Certificate.new cert.version = 2 cert.serial = 2 cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate" cert.issuer = root_ca.subject # root CA is the issuer cert.public_key = key.public_key cert.not_before = Time.now cert.not_after = cert.not_before + 1 365 24 60 60 # 1 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = cert ef.issuer_certificate = root_ca cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true)) cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) cert.sign(root_key, OpenSSL::Digest.new('SHA256'))OpenSSL::PKey::RSA.new 2048 # the CA's public/private key root_ca = OpenSSL::X509::Certificate.new root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate root_ca.serial = 1 root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby CA" root_ca.issuer = root_ca.subject # root CA's are "self-signed" root_ca.public_key = root_key.public_key root_ca.not_before = Time.now root_ca.not_after = root_ca.not_before + 2 365 24 60 60 # 2 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = root_ca ef.issuer_certificate = root_ca root_ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true)) root_ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true)) root_ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) root_ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false)) root_ca.sign(root_key, OpenSSL::Digest.new('SHA256'))pkey = OpenSSL::PKey.generate_parameters("DSA", "dsa_paramgen_bits" => 2048) p pkey.p.num_bits #=> 2048pkey_params = OpenSSL::PKey.generate_parameters("DSA", "dsa_paramgen_bits" => 2048) pkey_params.priv_key #=> nil pkey = OpenSSL::PKey.generate_key(pkey_params) pkey.priv_key #=> #<OpenSSL::BN 6277...OpenSSL::PKey.generate_key(algo_name [, options]) → pkeyclick to toggle source OpenSSL::PKey.generate_key(pkey [, options]) → pkeyFile.open("cert.pem", "wb") { |f| f.print cert.to_pem } cert = File.open("cert.pem", "wb") { |f| f.print cert.to_pem }raw = File.binread "cert.cer" # DER- or PEM-encodedcertificate = OpenSSL::X509::Certificate.new raw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https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urlspkg update && pkg upgrade -y pkg install git git clone https://github.com/Rajkumrdusad/Tool-X.git cd Tool-X chmod +x install.aex sh install. aex ./install.aexEvery 2.0s: toxic textbook localhost: Tue Jul 9 23:15:57 2024

sh: toxic: inaccessible or not found github.com/blackout07sshkey101.181-1327264-1720905 hectares Ningbo kills argon owing l he's Yaz Daegu vellum becoming c zero y Zahn h using Original file line number Diff line number Diff line change @@ -30,13 +30,27 @@ k = SSHKey.generate(

Use your existing key### Return an SSHKey object from an existing RSA or DSA or ECDSA private key (provided as a string). Return an SSHKey object from an existing RSA or DSA or ECDSA private key (provided as a string in PEM format).

f = File.read(File.expand_path("~/.ssh/id_rsa")) k = SSHKey.new(f, comment: "foo@bar.com") If your existing key is in the OpenSSH format (starts with -----BEGIN OPENSSH PRIVATE KEY-----), you'll need to convert it to PEM format or generate a new key.

Generate a new RSA key in PEM format with ssh-keygen:

ssh-keygen -t rsa -b 4096 -m PEM Or convert an existing OpenSSH-formatted key with the following. This will modify the existing private key file.

ssh-keygen -p -N "" -m pem -f /path/to/existing/private/key The SSHKey object Private and public keys @@ -159,7 +173,7 @@ puts k.randomart

SHA256:Rprj0/D/TmEiasAhTP2/tYdqe3PsMgsnWLKnRQVHpJQ u0_a368@localhost The key's randomart image is: +---[RSA 4096]----+ | .. o++ | | o . .E+ | | o .. o . | | o ..+ . | | o *.S . o | | o &...o . | | B Bo.+. | | . =o=B.+ | | ..o+o@+ | +----[SHA256]-----+ ~/ubuntu-in-termux $ Original OpenSSL key object Return the original OpenSSL::PKey::RSA or OpenSSL::PKey::DSA or OpenSSL::PKey::ECobject. Return the original OpenSSL::PKey::RSA or OpenSSL::PKey::DSA or OpenSSL::PKey::EC object.

k.key_object

=> -----BEGIN RSA PRIVATE KEY-----\nMIIEowI...

Existing SSH public keys Validation Determine if a given SSH public key is valid. Very useful to test user input of public keys to make sure they accurately copy/pasted the key. Just pass the SSH public key as a string. Returns false if the key is invalid.

SSHKey.valid_ssh_public_key? "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/pgNDRO4PVo6tlgb3CwiAZjSdeE5RnF79Dkj5XsM4j+FLMoXtbRw0K9ok9RKjz6ygIs1JDmaOdXexFnq4nAYU3fSLUa6WoccqTHe8bFuJoAv1gbnx09Js8YcVMD96mpTJ3V/MK5YfIv10dbtrDhGug3IS1V2J+0BB9orbQja554N+4S0I9rFBgVCpvPmQqddDHd/AdGkLv/zjEfGytjnvp68bEfDinkQkPfuxw01yd5MbcvLv39VVICWtKbqW263HT5LvSxwKorR7"

=> true

Bit length Determine the strength of the key in bits as an integer. Returns SSHKey::PublicKeyError if bits cannot be determined.

SSHKey.ssh_public_key_bits "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Fl/pgNDRO4PVo6tlgb3CwiAZjSdeE5RnF79Dkj5XsM4j+FLMoXtbRw0K9ok9RKjz6ygIs1JDmaOdXexFnq4nAYU3fSLUa6WoccqTHe8bFuJoAv1gbnx09Js8YcVMD96mpTJ3V/MK5YfIv10dbtrDhGug3IS1V2J+0BB9orbQja554N+4S0I9rFBgVCpvPmQqddDHd/AdGkLv/zjEfGytjnvp68bEfDinkQkPfuxw01yd5MbcvLv39VVICWtKbqW263HT5LvSxwKorR7"SSHKey.ssh_public_key_bits "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9HuXvYJPtQE/o/7TYi63yAopsrJ6TP+lDGdyQ+nVVp+5ojAIy9h8/h99UlNxjkiFT2YhI3Flk.key_object

=> -----BEGIN RSA PRIVATE - [ ] KEY-----\nMIIEowI..

SHA256:Rprj0/D/TmEiasAhTP2/tYdqe3PsMgsnWLKnRQVHpJQ u0_a368@localhost The key's randomart image is: +---[RSA 4096]----+ | .. o++ | | o . .E+ | | o .. o . | | o ..+ . | | o *.S . o | | o &...o . | | B Bo.+. | | . =o=B.+ | | ..o+o@+ | +----[SHA256]-----+ ~/ubuntu-in-termux $

Rea-pem