当使用JSch将私钥用作SFTP传输的标识文件时,为什么要将公钥添加到授权密钥中



当我们需要将公钥添加到授权密钥时,为什么我们使用带有私钥的身份文件身份验证进行sftp传输

Session session = null;
ChannelSftp sftpChannel = null;
JSch jsch = new JSch();        
try
{
    session = jsch.getSession( targetUserId, targetHost, targetPort );
    session.setConfig( "StrictHostKeyChecking", "no" );
    if( identityFile != null )
    {
        jsch.addIdentity( identityFile );
    }
    if( targetPassword != null )
    {
        session.setPassword( targetPassword );
    }
    session.connect();

SSH公钥身份验证使用非对称加密。

你有一个密钥对,其中一个密钥被称为私有(身份),另一个被称为公共。用私钥加密的内容可以用公钥解密,反之亦然。因此,服务器需要拥有您的公钥才能解密来自您(JSch SSH客户端)的SSH流量。

阅读有关公钥加密的信息。

最新更新