Support private key for ssh
This commit is contained in:
parent
64e86994f7
commit
fe6cc42d28
5 changed files with 16 additions and 2 deletions
11
.vscode/sftp.json
vendored
Normal file
11
.vscode/sftp.json
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "laplace",
|
||||
"host": "10.110.8.9",
|
||||
"username": "root",
|
||||
"password": "teamw9rk",
|
||||
"remotePath": "/root/tmp/webssh2",
|
||||
"protocol": "sftp",
|
||||
"port": 22,
|
||||
"uploadOnSave": true,
|
||||
"ignore": [".vscode", ".git", ".DS_Store", "node_modules", "vendor"]
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
FROM node:16-alpine
|
||||
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||
RUN apk update && apk add bash
|
||||
|
||||
WORKDIR /usr/src
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"listen": {
|
||||
"ip": "0.0.0.0",
|
||||
"port": 2224
|
||||
"port": 2222
|
||||
},
|
||||
"socketio": {
|
||||
"serveClient": false,
|
||||
|
|
|
|||
|
|
@ -53,9 +53,10 @@ exports.connect = function connect(req, res) {
|
|||
}
|
||||
}
|
||||
|
||||
if (req.method === 'POST' && req.body.username && req.body.userpassword) {
|
||||
if (req.method === 'POST' && req.body.username && (req.body.userpassword || req.body.privatekey)) {
|
||||
req.session.username = req.body.username;
|
||||
req.session.userpassword = req.body.userpassword;
|
||||
req.session.privatekey = req.body.privatekey;
|
||||
|
||||
if (req.body.port && validator.isInt(`${req.body.port}`, { min: 1, max: 65535 }))
|
||||
port = req.body.port;
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ module.exports = function appSocket(socket) {
|
|||
const { ssh } = socket.request.session;
|
||||
ssh.username = socket.request.session.username;
|
||||
ssh.password = socket.request.session.userpassword;
|
||||
ssh.privateKey = socket.request.session.privatekey;
|
||||
ssh.tryKeyboard = true;
|
||||
ssh.debug = debug('ssh2');
|
||||
conn.connect(ssh);
|
||||
|
|
|
|||
Loading…
Reference in a new issue