MACBOOK 远程访问服务器发布后台 您所在的位置:网站首页 ssh入侵一个服务器 MACBOOK 远程访问服务器发布后台

MACBOOK 远程访问服务器发布后台

2023-04-08 00:37| 来源: 网络整理| 查看: 265

接盘的一个后台项目修改一些问题之后需要发布到测试环境,于是打包之后开始连接远程服务器

用ssh -p 用户名@服务器地址,报错:Bad port

解决方法:需要在用户名之前加上一个默认的端口号22

ssh -p 22 用户名@服务器地址

输入密码之后连接成功,接下来取得管理员权限

sudo su

进入到发布文件的目录

cd 目录

接下来就是下载上传文件的操作了,在这里遇到了一个问题,在输入rz回车之后出现报错:rz waiting to receive.**B0100000023be50

解决方法:

1、安装lrzsz

brew install lrzsz

2、用命令行新建两个脚本(脚本来自某国外大神)

vim /usr/local/bin/iterm2-recv-zmodem.sh

vim /usr/local/bin/iterm2-send-zmodem.sh

第一个命令行之后出来一大块空白突然不知道该怎么办了,于是又顺便研究了vim的使用,就只需要把脚本复制粘贴到空白区域,然后

:w

保存

:q

退出,就可以在目录中看到这两个文件了

然后给这两个文件赋予权限

chmod 777 /usr/local/bin/iterm2-*

以下是两个脚本,按顺序,不知道为啥复制进来就是一大坨,试了试复制出去又是一大坨,任命的断句,我真是拴Q,简书快出个能自动识别代码的出来吧

#!/bin/bash

# Author: Matt Mastracci ([email protected])

# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script

# licensed under cc-wiki with attribution required

# Remainder of script public domain

osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm

if [[ $NAME = "iTerm" ]]; then

    FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script ("echo "&(quoted form of POSIX path of thefile as Unicode text)&"")"`

else

    FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script ("echo "&(quoted form of POSIX path of thefile as Unicode text)&"")"`

fi

if [[ $FILE = "" ]]; then

    echo Cancelled.

    # Send ZModem cancel

    echo -e \x18\x18\x18\x18\x18

    sleep 1

    echo

    echo # Cancelled transfer

else

    cd "$FILE"

    # /usr/local/bin/rz 这个需要根据自己安装的文件位置编写

    /usr/local/bin/rz -E -e -b

    sleep 1

    echo

    echo

    echo # Sent -> $FILE

fi

#!/bin/bash

# Author: Matt Mastracci ([email protected])

# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script

# licensed under cc-wiki with attribution required

# Remainder of script public domain

osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm

if [[ $NAME = "iTerm" ]]; then

    FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`

else

    FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`

fi

if [[ $FILE = "" ]]; then

    echo Cancelled.

    # Send ZModem cancel

    echo -e \\x18\\x18\\x18\\x18\\x18

    sleep 1

    echo

    echo \# Cancelled transfer

else

    # /usr/local/bin/sz 这个需要根据自己安装的文件位置编写

    /usr/local/bin/sz "$FILE" --escape --binary --bufsize 4096

    sleep 1

    echo

    echo \# Received $FILE

fi

3、下载一个叫做iterm2应用,下载地址很多,可以自己搜搜

4、配置iTerm,打开Preferences

😈:蠢蠢的我找了半天iTerm2这个东西,然后才发现需要自己去下载安装,于是才有了第三步

添加进去这两行,顺序不要放反,不然上传下载就完犊子了

Regular expression: rz waiting to receive.\*\*B0100

Action: Run Silent Coprocess

Parameters: /usr/local/bin/iterm2-send-zmodem.sh

Regular expression: rz waiting to receive.\*\*B0100

Action: Run Silent Coprocess

Parameters: /usr/local/bin/iterm2-recv-zmodem.sh

5、执行rz,就可以选择要上传的文件啦!🎉

注意:服务器也需要安装(可能我访问的服务器已经安装,这一步就没用到)

# centos

yum install lrzsz

#ubuntu

apt-get install lrzsz



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有