windows通过ssh去连接Linux服务器
windows 机器去连接远端服务器中的linux系统。linux系统由docker容器启动,默认是root 账号。sshd 默认禁止root账号登陆, 比较简单的是通过ssh的密钥直接登陆。另外,linux 系统不能访问外网,需要传递文件。
linux开启ssh服务
- ubuntu系统
service ssh start
- 如果是镜像自动拉起,添加启动命令
/sbin/sshd -D
vscode 远程开发使用
-
将windows的系统中生成ssh密钥。 在git bash 中 用ssh-keygen 生成密钥对。
$ ssh-keygen- 看到下面提示直接按Enter键,即可。 即在 ~/.ssh/目录下得到id_rsa 和id_rsa.pub 两个密钥文件,对应私钥和共钥。
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/pcp/.ssh/id_rsa):
- 看到下面提示直接按Enter键,即可。 即在 ~/.ssh/目录下得到id_rsa 和id_rsa.pub 两个密钥文件,对应私钥和共钥。
-
复制共钥文件内容,粘贴到linux 系统的授权key文件中
~/.ssh/authorized_keys. -
在windows系统中配置
~/.ssh/config登陆信息, 方便用ssh swift直接登陆
Host swift
HostName 172.23.254.15
User root
Port 30299
- 在vscode 中, 通过ssh-remote插件链接

winscp 传递文件
- mac 或者linux 系统下,可以直接用 scp 命令传递文件。windows 推荐用winscp,图形化操作。
- 没有密码,因此需要密钥登陆,具体配置参考 https://www.cnblogs.com/doublexi/p/9835346.html

--- 她说, 她是仙,她不是神

浙公网安备 33010602011771号