导航:首页 > IDC知识 > ssh服务器下载文件

ssh服务器下载文件

发布时间:2020-11-21 19:05:21

1、win7下用SSH下载远程服务器(linux系统)的文件到本地命令怎么打?

使用sftp 功能,下载个 filezilla ,这个软件有,使用比较简单。

使用 sz,rz 命令,linux 上要安装一下

2、请问:ssh从linux服务器下载文件的默认路径如何更改呢?

在你的ssh软件那里有设置,比如我的ssh软件事secure CRT 点击选项-会话选项-xymodenm那里又上传下载的路径,您改一下就好了

3、mac命令行 从linux服务器下载文件到本地

怎么用mac命令行从linux服务器下载文件到本地?

用mac命令行从linux服务器下载文件到本地的方法:连接服务器-写入命令-输入密码-下载即可。

具体步骤:

一、给电脑连上网,然后得知道服务器的帐号和密码,可以用ssh连接上服务器。输入ssh 用户名@主机名 ,回车提示输入密码,回车出现“welcome……”字样,代表连接成功。

二、写命令“scp 用户名@主机名:要下载的文见路径 要保存的位置”,回车。

三、输入密码,输入后回车,看到下载进度为100%时,下载成功。

四、在保存的位置处可以看见下载下来的文件。

4、谁有SSH上传下载文件的代码?

上传:

package com.wb.ekeng.web.action.file;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessages;

import com.wb.ekeng.ebo.BO_File;
import com.wb.ekeng.info.INFO_Admin;
import com.wb.ekeng.info.INFO_File;
import com.wb.ekeng.web.action.BaseAction;
import com.wb.ekeng.web.filemanage.File;
import com.wb.ekeng.web.filemanage.SmartUpload;
import com.wb.ekeng.web.util.Convertor;

public class ACT_AddFile extends BaseAction {

public ACT_AddFile() {
super();
}

public ActionForward doExcute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, ActionMessages errors) throws Exception {
//文件保存路径
String strSavePath ="/upload/file/";
//允许上传的文件类型
String strAllowExt ="jpg,jpeg,gif,bmp,txt,java";
//允许上传最大字节数
int maxSize =1048576;
//上传文件
SmartUpload upload=new SmartUpload();
upload.initialize(this.getServlet().getServletConfig(), request, response);
upload.upload("UTF-8");
//获取文件
String[] allowExtList =strAllowExt.split(",");
File fileBuffer =upload.getFiles().getFile(0);
if(fileBuffer.isMissing()){
throw new Exception("error.act.act_addfile.error3");
}

HttpSession session=request.getSession();
INFO_Admin loginAdmin=(INFO_Admin) session.getAttribute("loginadmin");
Long lAdminId=loginAdmin.getId();

String strName=upload.getRequest().getParameter("name");
//如果遇见上传中文文件出现乱码问题,上一句可以改成这样(其他语句参照这): String strName=new String(upload.getRequest().getParameter("name").getBytes(),"UTF-8");
String strNeedPoint=upload.getRequest().getParameter("needpoint");
String strType=upload.getRequest().getParameter("type");
String strDes=upload.getRequest().getParameter("des");

Integer iNeedPoint=null;

//验证参数
if(strName==null||strNeedPoint==null||strType==null||strDes==null){
throw new Exception("error.common.badrequest");
}
this.doValidate(errors,INFO_File.validateName(strName));
this.doValidate(errors,INFO_File.validateNeedPoint(strNeedPoint));
this.doValidate(errors,INFO_File.validateType(strType));
this.doValidate(errors,INFO_File.validateDes(strDes));

//验证文件大小
int FileSize=fileBuffer.getSize();
if(FileSize>maxSize){
this.doValidate(errors,"error.act.act_addfile.error2");
}

//验证文件类型
String strFileExt =fileBuffer.getFileExt();
boolean flag =false;
for(int i=0;i<allowExtList.length;i++) {
if(allowExtList[i].toLowerCase().equals(strFileExt.toLowerCase())){
//找到了匹配的后缀
flag=true;
}
}
if(strFileExt.equals("") || flag ==false){
this.doValidate(errors,"error.act.act_addfile.error1");
}

if(!errors.isEmpty()){
System.out.println(errors.toString());
return null;
}
//参数转换
strName =Convertor.convertHalfToFull(strName);
iNeedPoint=new Integer(strNeedPoint);
Integer iFileSize=Integer.valueOf(FileSize);

//构造saveName
String strSaveName=lAdminId+"_"+BO_File.getNowString()+"."+upload.getFiles().getFile(0).getFileExt();
fileBuffer.saveAs(strSavePath + strSaveName);

//提交数据
BO_File boFile=new BO_File();
boFile.addFile(strName,strType,strDes,strSaveName,iNeedPoint,lAdminId,iFileSize);
return new ActionForward("/admin/main/download/admindownload.do",true);
}
}

下载:
package com.wb.ekeng.web.action.file;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessages;

import com.wb.ekeng.web.action.BaseAction;
import com.wb.ekeng.ebo.BO_File;
import com.wb.ekeng.info.INFO_File;
import com.wb.ekeng.info.INFO_User;

import com.wb.ekeng.web.filemanage.SmartUpload;

/**
* 备注:
* 文件下载Action
* 输入:
* String fileid
* String userid
* 输出:
*/
public class ACT_Download extends BaseAction {

public ACT_Download() {
super();
}
public ActionForward doExcute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, ActionMessages errors) throws Exception {
HttpSession session =request.getSession();
//获取参数
Long lFileId=null;
String fileId =request.getParameter("fileid");
INFO_User infoUser=(INFO_User)session.getAttribute("loginuser");

//验证参数
if(fileId==null || infoUser.getId() ==null){
throw new Exception("error.common.badrequest");
}
lFileId=new Long(fileId);
BO_File boFile=new BO_File();
INFO_File infoFile =null;

//判断用户是否为第一次下载
接收存储下载资源Id的session,然后判断要下载的资源Id是否没存在于当前登录的下载页表中(即是否是第一次下载),如果是则调用下载扣除积分方法,并把这个资源的Id存入列表中。如果不是,则把标记位置false,直接下载资源,不调用扣除积分的方法。
boolean isFirstDownLoad =true;
ArrayList downFileList =(ArrayList)session.getAttribute("downfilelist");
for(int index =0; index <downFileList.size(); index ++){
Long lFileIdBuffer =(Long)downFileList.get(index);
if(lFileIdBuffer.longValue() ==lFileId.longValue()){
isFirstDownLoad =false;
break;
}
}
if(isFirstDownLoad){
infoFile=boFile.download(lFileId,infoUser.getId());
downFileList.add(lFileId);
}else{
infoFile=boFile.getFile(lFileId);
}
(下面就是有关下载的代码)
//新建一个SmartUpload对象
SmartUpload su = new SmartUpload();
//初始化
su.initialize(this.getServlet().getServletConfig(), request, response);
//设定contentDisposition为null以禁止浏览器自动打开文件,
//保证点击链接后是下载文件。若不设定,则下载的文件扩展名为
//doc时,浏览器将自动用word打开它。扩展名为pdf时,
//浏览器将用acrobat打开。
su.setContentDisposition(null);
//下载文件
su.downloadFile("/upload/file/"+infoFile.getSaveName());
return mapping.findForward("success");
}}

5、怎么用mac命令行从linux服务器下载文件到本地?

怎么用mac命令行从linux服务器下载文件到本地?

用mac命令行从linux服务器下载文件到本地的方法:连接服务器-写入命令-输入密码-下载即可。

具体步骤:

一、给电脑连上网,然后得知道服务器的帐号和密码,可以用ssh连接上服务器。输入ssh 用户名@主机名 ,回车提示输入密码,回车出现“welcome……”字样,代表连接成功。

二、写命令“scp 用户名@主机名:要下载的文见路径 要保存的位置”,回车。

三、输入密码,输入后回车,看到下载进度为100%时,下载成功。

四、在保存的位置处可以看见下载下来的文件。

6、ubuntu ssh 无法从服务器下载文件到本地?

后面跟上本地路径,下载到当前目录:
scp -r [email protected]:/var/lamp/abc.txt ./
下载到/tmp:
scp -r [email protected]:/var/lamp/abc.txt /tmp

7、请教:用ssh从linux服务器下载文件到本地总是弹出"Running Error"“abnormal program termination”

你这ssh软件不行,跟系统有冲突,换一个,比如SecureCRT/FX

8、linux 如何从远程终端下载文件到本地磁盘? 我的系统也是linux的,想从远程终端(ssh.)上复制文件到本地

第一种方式:

SecureCRT下
上传文件只需在终端仿真器中输入命令“rz”,即可从弹出的对话框中选择本地磁盘上的文件,利用Zmodem上传到服务器当前路径下。
下载文件只需在shell终端仿真器中输入命令“sz 文件名”,即可利用Zmodem将文件下载到本地某目录下。
通过“File Transfer”可以修改下载到本地的默认路径。设置默认目录:options-->session options-->file transfer。


或者

下载文件存放位置在securtCRT中设置,位于:


英文版 options — session options — X/Y/Zmodem。


中文版 选项— 会话选项— X/Y/Zmodem。

第二种方式:用sftp
securecrt 按下ALT+P就开启新的会话 进行ftp操作。
输入:help命令,显示该FTP提供所有的命令
pwd:  查询linux主机所在目录(也就是远程主机目录)
lpwd: 查询本地目录(一般指windows上传文件的目录:我们可以通过查看”选项“下拉框中的”会话选项“,如图二:我们知道本地上传目录为:D:/我的文档)
ls: 查询连接到当前linux主机所在目录有哪些文件
lls:  查询当前本地上传目录有哪些文件
lcd:  改变本地上传目录的路径
cd: 改变远程上传目录
get:  将远程目录中文件下载到本地目录
put:  将本地目录中文件上传到远程主机(linux)
quit: 断开FTP连接

9、使用windows客户端ssh远程连接linux主机,怎么进行文件的上传下载

如果你的windows安装了openssh软件,那么直接用 ‘sftp 登陆用户名@远端linux的IP’ 就可以登陆传输东西了,里面的命专令跟ftp很像,先cd到你要传的文件所在的目录,然后用‘属lcd’设置本地上传下载的目录,然后用’get或者put‘上传下载。如果你不想这么麻烦,直接下个ftp工具就好了。我平时都用的’fz‘全称’filezilla‘。直接连过去,图形界面操作,简单快捷

与ssh服务器下载文件相关的知识