标签: key-pair

为什么我无法连接到 ssh 反向隧道?

我正在用来autossh -M 20000 -fN -R 19999:localhost:22 -i mycert.pem ubuntu@myaws.hopto.org建立到我的 aws 机器的反向隧道。现在,当我尝试从 访问机器时aws,我得到以下信息:

$ ssh ron@localhost -P 19999
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)

为什么会这样呢?详细选项显示:

$ ssh ron@localhost -v -P 19999
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/ubuntu/.ssh/id_rsa type -1
debug1: key_load_public: No such file or …
Run Code Online (Sandbox Code Playgroud)

authentication amazon-ec2 ssh-tunnel key-pair

5
推荐指数
1
解决办法
4147
查看次数

Rsync 到 Amazon Linux EC2 实例 - 权限拒绝

只是为了运行测试,我想将一个图像文件从我的桌面放入我的一个实例文件夹中。

我已经尝试过在同一主题问题中提供的解决方案: Rsync to Amazon Ec2 Instance

所以我试过:

sudo rsync  -azv --progress -e "ssh -i ~/.ssh/MyKeyPair.pem" \ ~/Desktop/luffy.jpg  \ec2-user@xx.xx.xx.xxx:/home/ec2-user/myproject/mysite/mysite/media
Run Code Online (Sandbox Code Playgroud)

~/.ssh/是 MyKeyPair.pem 所在的位置。事实上,要通过 ssh 进入,我首先执行cd ~/.ssh然后我运行ssh -i ...命令。

但我收到此错误:

Warning: Identity file ~/.ssh/MyKeyPair.pem not accessible: No such file or directory.
Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]
Run Code Online (Sandbox Code Playgroud)

我在另一个问答页面上读到有人报告了同样的错误,他通过 yum 安装 rsync 解决了这个问题。就我而言,它已经安装(版本 3.0.6)。

如果有人可以提供帮助,我将不胜感激!

rsync amazon-ec2 permission-denied key-pair

4
推荐指数
1
解决办法
4323
查看次数

为什么 KeyPairGeneratorSpec 在 API < 24 上抛出 InvalidAlgorithmParameterException

当我在 API 24 中使用此 KeyPairGeneratorSpec 对象时,我的类可以正常工作。

KeyPairGeneratorSpec spec = new KeyPairGeneratorSpec.Builder(this)
                    .setAlias(KEY_ALIAS)
                    .setSubject(new X500Principal("CN=" + KEY_ALIAS))
                    .setSerialNumber(BigInteger.TEN)
                    .setStartDate(start.getTime())
                    .setEndDate(end.getTime())
                    .build();
            KeyPairGenerator kpg = KeyPairGenerator.getInstance(RSA);
            kpg.initialize(spec);
            keyPair = kpg.generateKeyPair();
Run Code Online (Sandbox Code Playgroud)

在低于 24 的版本上编译时,出现以下错误:

java.security.InvalidAlgorithmParameterException: Only RSAKeyGenParameterSpec supported
Run Code Online (Sandbox Code Playgroud)

我不明白,因为 KeyPairGeneratorSpec 应该可以从 api 18 获得?

android key-pair android-keystore

4
推荐指数
1
解决办法
1351
查看次数

加密/ssh ParsePublicKey“短读”错误

在我正在开发的程序中,我需要一种在开发过程中将公钥添加到 authorized_keys 文件的方法,因此我使用命令行参数来执行此操作。

我省略了大部分代码,但如果您想查看所有代码,这里是存储库,问题行位于 main.go 的第 20 行。

b, err := ioutil.ReadFile(os.Args[1])
if err != nil {
    log.Fatalf("Fatal error trying to read new public key file: %s", err)
}

newAuthorizedKey, err := ssh.ParsePublicKey(b)
if err != nil {
    log.Fatalf("Fatal error trying to parse new public key: %s", err)
}
Run Code Online (Sandbox Code Playgroud)

“短读”错误来自ssh.ParsePublicKey函数。我传入的命令行参数是要添加到该程序的authorized_keys 文件中的公钥的位置(例如~/.ssh/id_rsa.pub)。我已确保文件正确传递到程序中。

我查看了源代码,希望能调试这个“短读”错误,但我不知道发生了什么。ParsePublicKey函数源代码的位置crypto/ssh位于此处parseString函数源代码的位置,即ParsePublicKey函数用于生成“短读”错误的源代码位置,位于此处,也在crypto/ssh.

ssh go key-pair

4
推荐指数
1
解决办法
1851
查看次数

如何创建 aws ec2 公私密钥对

我正在遵循这个创建 aws 环境的指南。现在,在创建环境后,我想通过 ssh 连接到 ec2。

我需要的是创建私钥 - 公钥对,我不知道如何。

在指南的开头,它说:

Generate public key from private key
ssh-keygen -y -f ~/.ssh/pemfile/mumbai.pem
Run Code Online (Sandbox Code Playgroud)

但是我如何在我的主机上创建一个 mumbai.pem 文件呢?是否有下载创建此 pem 的命令,或者我需要从 aws 下载它?我对 aws 真的很陌生,我希望这不是太明显。

ssh amazon-web-services key-pair

4
推荐指数
1
解决办法
5346
查看次数

java使用密钥对加密和解密?

有谁知道如何使用RSA公钥和私钥加密和解密字符串对象?

我使用KeyPair生成器在下面创建了私钥和公钥,但我现在想要使用公钥来加密数据,并使用私钥来解密它.

public class Keys {

    private static KeyPairGenerator generator;

    private static KeyPair keyPair;

    private static PrivateKey mPrivateKey;

    private static PublicKey mPublicKey;

    private static SecureRandom secureRandom;

    private static final String SHA1PRNG = "SHA1PRNG";

    public static final String RSA = "RSA";

    private Keys() throws NoSuchAlgorithmException {
        generator = KeyPairGenerator.getInstance("RSA");
    }

    /**
     * Generate private and public key pairs
     * 
     * @throws NoSuchAlgorithmException
     */
    private static void generateKeyPair() throws NoSuchAlgorithmException {
        // create SecureRandom object used to generate key pairs

        secureRandom = …
Run Code Online (Sandbox Code Playgroud)

java encryption cryptography key-pair

3
推荐指数
1
解决办法
2066
查看次数

java.lang.IllegalArgumentException: string curve25519 不是 OID bouncycastle 1.52

我正在尝试使用曲线 25519 的 /java bouncy castle 1.52 实现生成密钥对,这给了我什么

java.lang.IllegalArgumentException: 字符串 curve25519 不是 OID

这是我的代码:

public KeyPair generateKeys() throws NoSuchAlgorithmException,
        NoSuchProviderException, InvalidAlgorithmParameterException {
    ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("curve25519");
    KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");
    g.initialize(ecSpec, new SecureRandom());

    return g.generateKeyPair();
}
Run Code Online (Sandbox Code Playgroud)

此代码的结果是下面的堆栈跟踪:

java.lang.IllegalArgumentException:字符串curve25519 不是org.bouncycastle.asn1.ASN1ObjectIdentifier.(Unknown Source) at org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey.getEncoded(Unknown Source) at org.bouncycastle的OID .provider.asymmetric.ec.BCECPrivateKey.getPublicKeyDetails(Unknown Source) at org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey.(Unknown Source) at org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi$EC. generateKeyPair(Unknown Source) at com.poc.databank.encryption.BouncyCastleEncryption.generateKeys(BouncyCastleEncryption.java:22) at com.poc.databank.encryption.BouncyCastleTest.testApp(BouncyCastleTest.java:16) at sun.reflect.NativeMethodAccessorImpl. invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl。invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod $1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)在 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 在 org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) 在 …

java cryptography bouncycastle elliptic-curve key-pair

3
推荐指数
1
解决办法
2308
查看次数

两个 EC2 实例之间的 ssh

我有两个 EC2 实例,我正在尝试查看是否可以通过 ssh 从一个实例连接到另一个实例。

如果我尝试从我的 Windows 实例到 PuTTY,它们中的每一个都可以工作(通过提供 .ppk 文件)。

现在,两个实例都关联到相同的密钥对,并且如果我检查其中.ssh/authorized_keys是否存在相同的公钥(显然是因为它引用了我在 AWS 中生成的相同密钥对)。

我尝试过,ssh <other host>但它要求我输入不存在的密钥密码。

所以我现在所做的是从实例 A 创建一个密钥对ssh-keygen,然后我尝试

ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
Run Code Online (Sandbox Code Playgroud)

但它给了我这个错误:

Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)

如果您有任何想法,欢迎提出。

ssh amazon-ec2 key-pair ssh-keygen

3
推荐指数
1
解决办法
4963
查看次数

ssh-keygen和openssl提供了两个不同的公钥

ssh-keygen和openssl是否可以从同一私钥生成两个不同的公钥?Command ssh-keygen -y -f ./my.key会给(ssh-rsa同一行之后的内容)与使用command 生成的一个(在-----BEGIN PUBLIC KEY-----和之间的内容)不同的公共密钥。-----END PUBLIC KEY-----openssl rsa -in my.key -pubout

encryption openssl rsa ssh-keys key-pair

3
推荐指数
1
解决办法
1620
查看次数

如何使用 BouncyCastle c# 将 RSA 公钥转换为字符串

我正在尝试将 RsaKeyParameter 公钥保存到 SQL 数据库中。我收到一个错误,提示 Bouncy Castle 无法将 RsaKeyParameters 转换为字节。

使用 BouncyCastle C#。

我生成了一个 RSA 密钥对,将私钥和公钥提取到变量中。然后我需要存储公钥以在应用程序的稍后阶段进行验证。

我找到了一篇关于转换为字节然后字符串的帖子,如下所示;

byte[] serializedPublicBytes = 
publicKeyInfo.ToAsn1Object().GetDerEncoded();
string serializedPublic = Convert.ToBase64String(serializedPublicBytes);
Run Code Online (Sandbox Code Playgroud)

但它不喜欢 ToAsn1Object。补充一下这是一个例子,我知道我的变量名是不同的。

        RsaKeyPairGenerator rsaKeyPairGen = new RsaKeyPairGenerator();
        rsaKeyPairGen.Init(new KeyGenerationParameters(new SecureRandom(), 2048));
        AsymmetricCipherKeyPair keyPair = rsaKeyPairGen.GenerateKeyPair();

        RsaKeyParameters PrivateKey = (RsaKeyParameters)keyPair.Private;
        RsaKeyParameters PublicKey = (RsaKeyParameters)keyPair.Public;
Run Code Online (Sandbox Code Playgroud)

公钥应该是字节,然后是字符串,以保存到数据库中。

c# rsa bouncycastle key-pair

3
推荐指数
1
解决办法
4990
查看次数