# jssh **Repository Path**: MGHM/jssh ## Basic Information - **Project Name**: jssh - **Description**: linux scp(文件上传,下载) shell命令的java ssh jar和linux expect工具,主要是避免shell 密码手工输入带来的麻烦(免密ssh,scp),简单易用,方便上手。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 8 - **Created**: 2018-08-29 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jssh #### 项目介绍 linux scp(文件上传,下载) shell命令的java ssh工具,主要是避免shell 密码手工输入带来的麻烦。 #### 软件架构 jssh.jar 使用jsch封装的java版本
jssh.sh 使用expect封装的sh版本

以上两者是独立的,不同的实现。
#### jssh.jar安装教程
wget https://gitee.com/chejiangyi/jssh/raw/master/release/master/jssh.jar
#### jssh.jar使用说明 命令格式:java -jar jssh.jar [用户名]@[ip]:[端口]@[密码] [命令] [命令参数...]
说明:
[用户名] root
[ip]10.200.133.69
[端口]22
[密码]cjy@@2018! (若@为转义,使用@@)
[命令]sftp (枚举:shell,sftp)
[参数]/root/setting.xml /root/setting.xml (根据命令指定参数)

shell命令:
支持 linux shell
exit (表示退出shell)

sftp命令:
sftp [get(下载)/put(上传)] [来源文件路径 [目标文件路径]

示范1(上传,下载同理):
java -jar jssh.jar root@10.200.133.69:22@123456 sftp put c:/setting.xml /root/setting.xml
![img1](http://images2018.cnblogs.com/blog/815689/201806/815689-20180622100140266-1620257899.png)
示范2(shell):
java -jar jssh.jar root@10.200.133.69:22@123456 shell <<EOF  
cd /
cat stream-mysql.log
exit
EOF
![img2](http://images2018.cnblogs.com/blog/815689/201806/815689-20180622101409578-253175765.png)
#### jssh.sh安装教程
yum install expect
wget https://gitee.com/chejiangyi/jssh/raw/master/release/master/jssh.sh
#### jssh.sh使用说明 命令格式:expect jssh.sh [命令] [用户名]@[ip]:[fromfile] [tofile] [remotepassword]

scp命令(下载): expect jssh.sh scp [用户名]@[ip]:[fromfile] [tofile] [remotepassword]
scp命令(上传): expect jssh.sh scp [fromfile] [用户名]@[ip]:[tofile] [remotepassword]
举例:
expect jssh.sh scp root@10.200.133.50:tt.sql /tt.sql 111@2017!
![img3](http://images2018.cnblogs.com/blog/815689/201806/815689-20180622101936261-468046790.png)
ssh命令:expect jssh.sh ssh [用户名]@[ip] [remotepassword]
举例:
expect jssh.sh ssh root@10.200.133.50 111@2017!
![img4](http://images2018.cnblogs.com/blog/815689/201806/815689-20180622102117601-1920746510.png)
#### 参与贡献 by 车江毅