merge
commit
ccbffa6731
|
@ -23,6 +23,9 @@ ssh - secure shell remote login client
|
||||||
] [
|
] [
|
||||||
.IR user @] host
|
.IR user @] host
|
||||||
[
|
[
|
||||||
|
.B -W
|
||||||
|
.I remote!port
|
||||||
|
] [
|
||||||
.I cmd
|
.I cmd
|
||||||
.I args
|
.I args
|
||||||
.I ...
|
.I ...
|
||||||
|
@ -83,6 +86,13 @@ with the
|
||||||
.B -r
|
.B -r
|
||||||
option.
|
option.
|
||||||
.PP
|
.PP
|
||||||
|
With the
|
||||||
|
.B -W
|
||||||
|
option, instead of executing a command remotely, makes
|
||||||
|
the server dial a tcp connection to
|
||||||
|
.I remote!port
|
||||||
|
which the client relays on standard input and output.
|
||||||
|
.PP
|
||||||
The
|
The
|
||||||
.B -d
|
.B -d
|
||||||
option enables debug output.
|
option enables debug output.
|
||||||
|
|
|
@ -80,8 +80,8 @@ int nsid;
|
||||||
uchar sid[256];
|
uchar sid[256];
|
||||||
char thumb[2*SHA2_256dlen+1], *thumbfile;
|
char thumb[2*SHA2_256dlen+1], *thumbfile;
|
||||||
|
|
||||||
int fd, intr, raw, debug;
|
int fd, intr, raw, port, debug;
|
||||||
char *user, *service, *status, *host, *cmd;
|
char *user, *service, *status, *host, *remote, *cmd;
|
||||||
|
|
||||||
Oneway recv, send;
|
Oneway recv, send;
|
||||||
void dispatch(void);
|
void dispatch(void);
|
||||||
|
@ -1147,7 +1147,7 @@ kfmt(Fmt *f)
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: %s [-dR] [-t thumbfile] [-T tries] [-u user] [-h] [user@]host [cmd args...]\n", argv0);
|
fprint(2, "usage: %s [-dR] [-t thumbfile] [-T tries] [-u user] [-h] [user@]host [-W remote!port] [cmd args...]\n", argv0);
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,6 +1173,17 @@ main(int argc, char *argv[])
|
||||||
case 'd':
|
case 'd':
|
||||||
debug++;
|
debug++;
|
||||||
break;
|
break;
|
||||||
|
case 'W':
|
||||||
|
remote = EARGF(usage());
|
||||||
|
s = strrchr(remote, '!');
|
||||||
|
if(s == nil)
|
||||||
|
s = strrchr(remote, ':');
|
||||||
|
if(s == nil)
|
||||||
|
usage();
|
||||||
|
*s++ = 0;
|
||||||
|
port = atoi(s);
|
||||||
|
raw = 0;
|
||||||
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
raw = 0;
|
raw = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1221,6 +1232,9 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(remote != nil && cmd != nil)
|
||||||
|
usage();
|
||||||
|
|
||||||
if((fd = dial(netmkaddr(host, nil, "ssh"), nil, nil, nil)) < 0)
|
if((fd = dial(netmkaddr(host, nil, "ssh"), nil, nil, nil)) < 0)
|
||||||
sysfatal("dial: %r");
|
sysfatal("dial: %r");
|
||||||
|
|
||||||
|
@ -1260,11 +1274,27 @@ Next0: switch(recvpkt()){
|
||||||
recv.chan = 0;
|
recv.chan = 0;
|
||||||
|
|
||||||
/* open hailing frequencies */
|
/* open hailing frequencies */
|
||||||
sendpkt("bsuuu", MSG_CHANNEL_OPEN,
|
if(remote != nil){
|
||||||
"session", 7,
|
NetConnInfo *nci = getnetconninfo(nil, fd);
|
||||||
recv.chan,
|
if(nci == nil)
|
||||||
recv.win,
|
sysfatal("can't get netconninfo: %r");
|
||||||
recv.pkt);
|
sendpkt("bsuuususu", MSG_CHANNEL_OPEN,
|
||||||
|
"direct-tcpip", 12,
|
||||||
|
recv.chan,
|
||||||
|
recv.win,
|
||||||
|
recv.pkt,
|
||||||
|
remote, strlen(remote),
|
||||||
|
port,
|
||||||
|
nci->laddr, strlen(nci->laddr),
|
||||||
|
atoi(nci->lserv));
|
||||||
|
free(nci);
|
||||||
|
} else {
|
||||||
|
sendpkt("bsuuu", MSG_CHANNEL_OPEN,
|
||||||
|
"session", 7,
|
||||||
|
recv.chan,
|
||||||
|
recv.win,
|
||||||
|
recv.pkt);
|
||||||
|
}
|
||||||
|
|
||||||
Next1: switch(recvpkt()){
|
Next1: switch(recvpkt()){
|
||||||
default:
|
default:
|
||||||
|
@ -1307,36 +1337,38 @@ Next1: switch(recvpkt()){
|
||||||
|
|
||||||
/* child reads input and sends packets */
|
/* child reads input and sends packets */
|
||||||
qlock(&sl);
|
qlock(&sl);
|
||||||
if(raw) {
|
if(remote == nil){
|
||||||
rawon();
|
if(raw) {
|
||||||
sendpkt("busbsuuuus", MSG_CHANNEL_REQUEST,
|
rawon();
|
||||||
send.chan,
|
sendpkt("busbsuuuus", MSG_CHANNEL_REQUEST,
|
||||||
"pty-req", 7,
|
send.chan,
|
||||||
0,
|
"pty-req", 7,
|
||||||
tty.term, strlen(tty.term),
|
0,
|
||||||
tty.cols,
|
tty.term, strlen(tty.term),
|
||||||
tty.lines,
|
tty.cols,
|
||||||
tty.xpixels,
|
tty.lines,
|
||||||
tty.ypixels,
|
tty.xpixels,
|
||||||
"", 0);
|
tty.ypixels,
|
||||||
}
|
"", 0);
|
||||||
if(cmd == nil){
|
}
|
||||||
sendpkt("busb", MSG_CHANNEL_REQUEST,
|
if(cmd == nil){
|
||||||
send.chan,
|
sendpkt("busb", MSG_CHANNEL_REQUEST,
|
||||||
"shell", 5,
|
send.chan,
|
||||||
0);
|
"shell", 5,
|
||||||
} else if(*cmd == '#') {
|
0);
|
||||||
sendpkt("busbs", MSG_CHANNEL_REQUEST,
|
} else if(*cmd == '#') {
|
||||||
send.chan,
|
sendpkt("busbs", MSG_CHANNEL_REQUEST,
|
||||||
"subsystem", 9,
|
send.chan,
|
||||||
0,
|
"subsystem", 9,
|
||||||
cmd+1, strlen(cmd)-1);
|
0,
|
||||||
} else {
|
cmd+1, strlen(cmd)-1);
|
||||||
sendpkt("busbs", MSG_CHANNEL_REQUEST,
|
} else {
|
||||||
send.chan,
|
sendpkt("busbs", MSG_CHANNEL_REQUEST,
|
||||||
"exec", 4,
|
send.chan,
|
||||||
0,
|
"exec", 4,
|
||||||
cmd, strlen(cmd));
|
0,
|
||||||
|
cmd, strlen(cmd));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for(;;){
|
for(;;){
|
||||||
static uchar buf[MaxPacket];
|
static uchar buf[MaxPacket];
|
||||||
|
|
Loading…
Reference in New Issue