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『。直接連過去,圖形界面操作,簡單快捷