public class JschUtils extends Object
本实现用于直接采用 Private Key Content 登录。
Created by zhenqin. User: zhenqin Date: 2022/3/25 Time: 下午2:56 Email: zhzhenqin@163.com
| Modifier and Type | Field and Description |
|---|---|
static String |
FOOTER |
static String |
HEADER |
| Constructor and Description |
|---|
JschUtils() |
| Modifier and Type | Method and Description |
|---|---|
static com.jcraft.jsch.Session |
createSession(String sshHost,
int sshPort,
String sshUser,
String privateKey,
byte[] passphrase)
通过私钥获取 Session
|
public static final String HEADER
public static final String FOOTER
public static com.jcraft.jsch.Session createSession(String sshHost, int sshPort, String sshUser, String privateKey, byte[] passphrase)
sshHost - ssh 目标节点IP、域名、机器名sshPort - ssh 服务端口号,一般为 22sshUser - ssh 目标节点登录用户privateKey - 采用的私钥,一般由 ssh-keygen 生成。必须包含完整的前后缀:-----BEGIN RSA PRIVATE KEY-----passphrase - 密码Copyright © 2017–2022. All rights reserved.