1 ssh
創(chuàng)新互聯(lián)建站是一家專業(yè)提供大興企業(yè)網(wǎng)站建設(shè),專注與做網(wǎng)站、成都網(wǎng)站制作、HTML5建站、小程序制作等業(yè)務(wù)。10年已為大興眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。
$ ssh username@remotehost
用shh登陸服務(wù)器。
2、scp
命令scp基于SSH協(xié)議,可以將本地文件拷貝到遠(yuǎn)程服務(wù)上的指定目錄,格式如下:
$ scp filename username@remotehost:remotedirectory
執(zhí)行:$ scp ipmsg.log admin@10.25.1.202:/home/admin
3 ftp/sftp
首先用root用戶登錄遠(yuǎn)程Linux服務(wù)器,將admin用戶添加到FTP賬戶中。
通過echo命令追加一行到user_list文件中:# echo admin user_list
之后通過service命令開啟FTP服務(wù):# service vsftpd start
現(xiàn)在就可以在本機訪問FTP遠(yuǎn)程服務(wù)器了,然后通過put命令上傳文件了。
4 SSH Windows Client
SSH提供了一個scp2.exe作為Windows下的scp命令工具。
題主你好,
從服務(wù)器上下載文件或向服務(wù)器上傳文件最常用的命令當(dāng)屬scp了,使用方法也簡單.
一.先說題主問題中的情況,即從服務(wù)器上往回拿文件(官話一點的表達(dá):從服務(wù)器上將文件下載到本地):
scp 服務(wù)器用戶名@服務(wù)器ip:文件的絕對路徑 要將文件保存到本地哪
舉例來說,我的服務(wù)器地址是1.1.1.1,用戶名為hellofriend,并且在服務(wù)器上的/home/hellofriend/下有個名為ok的文件,則我想將服務(wù)器上的這個ok文件下載到本地的根目錄,/,下用到的命令為:
scp hellofriend@1.1.1.1:/home/hellofriend/ok /
命令執(zhí)行完成后,會提示你輸入hellofriend這個用戶的密碼,密碼輸入完成后,回車,正常情況下,你在根目錄下就能看到ok文件了.
*.新手注意事項:
a.ip地址和文件路徑中間有個冒號;
b.文件路徑一般用絕對路徑,即從根開始找;
c.不要忘了寫你要將文件保存在本地的哪里;
-----
二.再說如何將本地文件上傳到服務(wù)器,這個不細(xì)說,命令和上面的差不多:
scp 本地的文件路徑 服務(wù)器用戶名@服務(wù)器ip:要保存在服務(wù)器的哪個位置
如我要將本地根目錄下的ok文件上傳到1.1.1.1這臺服務(wù)器的/home/hellofriend目錄下,則命令為:
scp /ok root@1.1.1.1:/home/hellofriend/
執(zhí)行命令后,輸入密碼,回車,正常情況下文件就上傳成功了.
-----
寫在最后: 上面命令寫的其實相對死板一些,其實還有一些小技巧,題主用的多了就能了解了,這里先不過多展開.
=====
希望可以幫到題主, 歡迎追問.
在下邊圖示位置粘貼授權(quán)碼,耐心等待一會即可(1-2分鐘)
授權(quán)成功。
測試上傳和同步本地文件到云盤
由于百度PCS API權(quán)限限制,程序只能存取百度云端/apps/bypy目錄下面的文件和目錄。我們可以通過:
你是你是要通過git命令上傳東西,還是想上傳git到服務(wù)器上面,你可以先通過yum安裝git
#?yum?install?git
已加載插件:fastestmirror,?refresh-packagekit,?security
設(shè)置安裝進(jìn)程
Loading?mirror?speeds?linuxprobe.com?from?cached?hostfile
base????????????????????????????????????????????????????????????????????????????????????????????????????????????|?3.7?kB?????00:00?????
epel????????????????????????????????????????????????????????????????????????????????????????????????????????????|?4.3?kB?????00:00?????
epel/primary_db?????????????????????????????????????????????????????????????????????????????????????????????????|?5.9?MB?????00:05?????
extras??????????????????????????????????????????????????????????????????????????????????????????????????????????|?3.4?kB?????00:00?????
hhvm????????????????????????????????????????????????????????????????????????????????????????????????????????????|?2.9?kB?????00:00?????
shells_fish_release_2???????????????????????????????????????????????????????????????????????????????????????????|?1.2?kB?????00:00?????
updates?????????????????????????????????????????????????????????????????????????????????????????????????????????|?3.4?kB?????00:00?????
updates/primary_db??????????????????????????????????????????????????????????????????????????????????????????????|?821?kB?????00:01?????
upgrade?????????????????????????????????????????????????????????????????????????????????????????????????????????|?1.9?kB?????00:00?????
virtualbox/signature????????????????????????????????????????????????????????????????????????????????????????????|??181?B?????00:00?????
virtualbox/signature????????????????????????????????????????????????????????????????????????????????????????????|?1.1?kB?????00:00?...?
包?git-1.7.1-8.el6.x86_64?已安裝并且是最新版本
無須任何處理
#git?--help
usage:?git?[--version]?[--exec-path[=GIT_EXEC_PATH]]?[--html-path]
[-p|--paginate|--no-pager]?[--no-replace-objects]
[--bare]?[--git-dir=GIT_DIR]?[--work-tree=GIT_WORK_TREE]
[--help]?COMMAND?[ARGS]
The?most?commonly?used?git?commands?are:
add????????Add?file?contents?to?the?index
bisect?????Find?by?binary?search?the?change?that?introduced?a?bug
branch?????List,?create,?or?delete?branches
checkout???Checkout?a?branch?or?paths?to?the?working?tree
clone??????Clone?a?repository?into?a?new?directory
commit?????Record?changes?to?the?repository
diff???????Show?changes?between?commits,?commit?and?working?tree,?etc
fetch??????Download?objects?and?refs?from?another?repository
grep???????Print?lines?matching?a?pattern
init???????Create?an?empty?git?repository?or?reinitialize?an?existing?one
log????????Show?commit?logs
merge??????Join?two?or?more?development?histories?together
mv?????????Move?or?rename?a?file,?a?directory,?or?a?symlink
pull???????Fetch?from?and?merge?with?another?repository?or?a?local?branch
push???????Update?remote?refs?along?with?associated?objects
rebase?????Forward-port?local?commits?to?the?updated?upstream?head
reset??????Reset?current?HEAD?to?the?specified?state
rm?????????Remove?files?from?the?working?tree?and?from?the?index
show???????Show?various?types?of?objects
status?????Show?the?working?tree?status
tag????????Create,?list,?delete?or?verify?a?tag?object?signed?with?GPG
See?'git?help?COMMAND'?for?more?information?on?a?specific?command.
下面我給介紹一種從本地上傳到服務(wù)器的命令:
命令rz和sz命令,首先你需要安裝lrzsz庫
#rz?--help
rz?version?0.12.20
Usage:?rz?[options]?[filename.if.xmodem]
Receive?files?with?ZMODEM/YMODEM/XMODEM?protocol
(X)?=?option?applies?to?XMODEM?only
(Y)?=?option?applies?to?YMODEM?only
(Z)?=?option?applies?to?ZMODEM?only
-+,?--append????????????????append?to?existing?files
-a,?--ascii?????????????????ASCII?transfer?(change?CR/LF?to?LF)
-b,?--binary????????????????binary?transfer
-B,?--bufsize?N?????????????buffer?N?bytes?(N==auto:?buffer?whole?file)
-c,?--with-crc??????????????Use?16?bit?CRC?(X)
-C,?--allow-remote-commands?allow?execution?of?remote?commands?(Z)
-D,?--null??????????????????write?all?received?data?to?/dev/null
--delay-startup?N???????sleep?N?seconds?before?doing?anything
-e,?--escape????????????????Escape?control?characters?(Z)
-E,?--rename????????????????rename?any?files?already?existing
--errors?N??????????????generate?CRC?error?every?N?bytes?(debugging)
-h,?--help??????????????????Help,?print?this?usage?message
-m,?--min-bps?N?????????????stop?transmission?if?BPS?below?N
-M,?--min-bps-time?N??????????for?at?least?N?seconds?(default:?120)
-O,?--disable-timeouts??????disable?timeout?code,?wait?forever?for?data
--o-sync????????????????open?output?file(s)?in?synchronous?write?mode
-p,?--protect???????????????protect?existing?files
-q,?--quiet?????????????????quiet,?no?progress?reports
-r,?--resume????????????????try?to?resume?interrupted?file?transfer?(Z)
-R,?--restricted????????????restricted,?more?secure?mode
-s,?--stop-at?{HH:MM|+N}????stop?transmission?at?HH:MM?or?in?N?seconds
-S,?--timesync??????????????request?remote?time?(twice:?set?local?time)
--syslog[=off]??????????turn?syslog?on?or?off,?if?possible
-t,?--timeout?N?????????????set?timeout?to?N?tenths?of?a?second
-u,?--keep-uppercase????????keep?upper?case?filenames
-U,?--unrestrict????????????disable?restricted?mode?(if?allowed?to)
-v,?--verbose???????????????be?verbose,?provide?debugging?information
-w,?--windowsize?N??????????Window?is?N?bytes?(Z)
-X??--xmodem????????????????use?XMODEM?protocol
-y,?--overwrite?????????????Yes,?clobber?existing?file?if?any
--ymodem????????????????use?YMODEM?protocol
-Z,?--zmodem????????????????use?ZMODEM?protocol
short?options?use?the?same?arguments?as?the?long?ones
#sz?--help
sz?version?0.12.20
Usage:?sz?[options]?file?...
or:?sz?[options]?-{c|i}?COMMAND
Send?file(s)?with?ZMODEM/YMODEM/XMODEM?protocol
(X)?=?option?applies?to?XMODEM?only
(Y)?=?option?applies?to?YMODEM?only
(Z)?=?option?applies?to?ZMODEM?only
-+,?--append????????????????append?to?existing?destination?file?(Z)
-2,?--twostop???????????????use?2?stop?bits
-4,?--try-4k????????????????go?up?to?4K?blocksize
--start-4k??????????????start?with?4K?blocksize?(doesn't?try?8)
-8,?--try-8k????????????????go?up?to?8K?blocksize
--start-8k??????????????start?with?8K?blocksize
-a,?--ascii?????????????????ASCII?transfer?(change?CR/LF?to?LF)
-b,?--binary????????????????binary?transfer
-B,?--bufsize?N?????????????buffer?N?bytes?(N==auto:?buffer?whole?file)
-c,?--command?COMMAND???????execute?remote?command?COMMAND?(Z)
-C,?--command-tries?N???????try?N?times?to?execute?a?command?(Z)
-d,?--dot-to-slash??????????change?'.'?to?'/'?in?pathnames?(Y/Z)
--delay-startup?N???????sleep?N?seconds?before?doing?anything
-e,?--escape????????????????escape?all?control?characters?(Z)
-E,?--rename????????????????force?receiver?to?rename?files?it?already?has
-f,?--full-path?????????????send?full?pathname?(Y/Z)
-i,?--immediate-command?CMD?send?remote?CMD,?return?immediately?(Z)
-h,?--help??????????????????print?this?usage?message
-k,?--1k????????????????????send?1024?byte?packets?(X)
-L,?--packetlen?N???????????limit?subpacket?length?to?N?bytes?(Z)
-l,?--framelen?N????????????limit?frame?length?to?N?bytes?(l=L)?(Z)
-m,?--min-bps?N?????????????stop?transmission?if?BPS?below?N
-M,?--min-bps-time?N??????????for?at?least?N?seconds?(default:?120)
-n,?--newer?????????????????send?file?if?source?newer?(Z)
-N,?--newer-or-longer???????send?file?if?source?newer?or?longer?(Z)
-o,?--16-bit-crc????????????use?16?bit?CRC?instead?of?32?bit?CRC?(Z)
-O,?--disable-timeouts??????disable?timeout?code,?wait?forever
-p,?--protect???????????????protect?existing?destination?file?(Z)
-r,?--resume????????????????resume?interrupted?file?transfer?(Z)
-R,?--restricted????????????restricted,?more?secure?mode
-q,?--quiet?????????????????quiet?(no?progress?reports)
-s,?--stop-at?{HH:MM|+N}????stop?transmission?at?HH:MM?or?in?N?seconds
--tcp???????????????????build?a?TCP?connection?to?transmit?files
--tcp-server????????????open?socket,?wait?for?connection
-u,?--unlink????????????????unlink?file?after?transmission
-U,?--unrestrict????????????turn?off?restricted?mode?(if?allowed?to)
-v,?--verbose???????????????be?verbose,?provide?debugging?information
-w,?--windowsize?N??????????Window?is?N?bytes?(Z)
-X,?--xmodem????????????????use?XMODEM?protocol
-y,?--overwrite?????????????overwrite?existing?files
-Y,?--overwrite-or-skip?????overwrite?existing?files,?else?skip
--ymodem????????????????use?YMODEM?protocol
-Z,?--zmodem????????????????use?ZMODEM?protocol
short?options?use?the?same?arguments?as?the?long?ones
More?information?can?be?used?for?reference?linuxprobe.com。
在 Linux 系統(tǒng)提示符 $ 下,使用 ftp 命令,如下所示:
$ftp a.b.c.d cr (其中:a.b.c.d 為假設(shè)的一個對方的 FTP 服務(wù)器的 IP 地址)
如果是對方的 FTP 服務(wù)器允許別人進(jìn)行匿名訪問的話,那么用戶名就是:anonymous,密碼一般為空。否則的話,就需要輸入對方提前事先提供給你的用戶名和密碼才能夠進(jìn)行文件傳輸。
使用約定好的用戶名和密碼登錄到對方的 FTP 服務(wù)器之后,你就可以使用 put(傳輸單個文件)、或者 mput(傳輸多個文件)、get(從對方的FTP服務(wù)器上獲取單個文件)、mget(從對方的FTP服務(wù)器上獲取多個文件)了。當(dāng)然了,一般 FTP 服務(wù)器的系統(tǒng)管理員都會給你一個 /pub 子目錄,供所有用戶使用。所以一般來說,即使使用賬號登錄 FTP 服務(wù)器之后,第一個命令就是: cd /pub ,轉(zhuǎn)入公共子目錄。