文章目录
GUI方案
vnc Viewer
通用方案
scp方式下的文件传输(linux)
ssh远程编程
- 特别是远程主机没有安装图形界面的时候(节约云服务器的资源占用)
- 可以通过vscode提供的
remote-ssh
插件,来利用本地可视化编辑器(其他IDE可能也有其自己的远程编程支持)来编辑远程代码
这不是必须的,但是有时可以提供便利
Connect over SSH with Visual Studio Code
scp方式:
- 注意,有多台raspberry时,将
userName@RaspberrypiHostName
作
userName@<RaspberrryIP>
- 详情,查看
scp
帮助文档
- 在linux(或者windows wsl)下执行
man scp
获取帮助
windows_powershell+scp:
引用变量的方式
使用双引号引住变量名来引用主机名
PS D:\repos\blogs\linuxCommandsTutor> scp .\pets.txt cxxu@"$AliCloudServerIP":~ cxxu@12.xxx.xxx.67's password: pets.txt
- 但是无法将
userName@hostName
整个的用变量来代替
但可以编写函数:
function scp_ali {
<#
.Example
scp_ali .\pets.txt ~
_____
PS D:\repos\blogs\linuxCommandsTutor> scp_ali .\pets.txt ~
cxxu@12x.xx.x.7's password:
pets.txt
#>
param (
$source,
$TargetPath
)
scp $source "$cxxuAli`:$TargetPath"
}
cmd+scp也类似
sftp传输协议
sftp功能比较强大
- SFTP (SSH File Transfer Protocol) is a network protocol that provides file access, file transfer, and file management over any reliable data stream.
- It was designed by the Internet Engineering Task Force (IETF) as an extension of the Secure Shell protocol (SSH) version 2.0 to
provide secure file transfer capabilities
.
sftp相关工具(mobaXterm)
- 算是一款功能丰富的终端工具
- 免费版一般够用:下载MobaXterm Xserver with SSH, telnet, RDP, VNC and X11 - Download (mobatek.net)
- 支持文件拖曳进行双向传输,记住密码等管理功能
powershell+ssh连接
- 最简单的ssh连接用法
ssh remoteHostName@remoteHostIp
例如,我连接到本地的linux 虚拟机(ubuntu server)(局域网内的链接) - 购买的云主机也是类似的方式链接
注意,如果仅仅指定ip而不指定远程主机上的用户名,将无法以用户的形式登录控制远程主机
- 完整文档参考OpenSSH: Manual Pages
通过git部署最新代码
可以通过在本地修改代码,上传到github/gitee;在服务器(linux)端clone(pull)最新代码实现代码更新(也是基于ssh执行相应命令)
在这种做法下,一般不在服务端编辑代码,二至通过git 跟新代码
当然要传输二进制文件也是可以的.