自学内容网 自学内容网

screen使用——关机时在服务器上跑代码

一、连接服务器

原理:通过 SSH(Secure Shell)协议建立本地与远程服务器的安全连接通道,使得可以在本地操作服务器。


操作:使用 VSCode 或 cmd 的 ssh 连接到服务器,这里我选择cmd。

检查是否安装 OpenSSH

在 Windows 10 及以上版本中,系统可能已经自带 OpenSSH 客户端。打开命令提示符(cmd),输入 “ssh”,如果出现关于 SSH 的帮助信息,说明已经安装。

C:\Users\吴伊晴>ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
           [-i identity_file] [-J [user@]host[:port]] [-L address]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] destination [command]

连接到服务器

  1. 打开 cmd。
  2. 输入 “ssh username@server_ip”,其中 “username” 是你在服务器上的用户名,“server_ip” 是服务器的 IP 地址。
  3. 首次连接时,系统可能会提示你确认服务器的指纹,输入 “yes” 确认。
  4. 然后输入你的服务器密码,按下回车键。如果密码正确,你将成功连接到服务器。
C:\Users\吴伊晴>ssh -p 19100 root@i26mn82mwdjl6xzbsky.deepln.com
The authenticity of host '[i26mn82mwdjl6xzbsky.deepln.com]:19100 ([118.180.21.62]:19100)' can't be established.
ED25519 key fingerprint is SHA256:1wVKEfi7h61INBh5GA9wJsS9+EdeBMgWmY/Rja1xG9Q.
This host key is known by the following other names/addresses:
    C:\Users\吴伊晴/.ssh/known_hosts:35: [zikdwu07oynmyzrqsnow.deepln.com]:40457
    C:\Users\吴伊晴/.ssh/known_hosts:38: [hqvumkbagsino1vosnow.deepln.com]:54718
    C:\Users\吴伊晴/.ssh/known_hosts:39: [dv9owtzqvjzr4chdzky.deepln.com]:19100
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[i26mn82mwdjl6xzbsky.deepln.com]:19100' (ED25519) to the list of known hosts.
root@i26mn82mwdjl6xzbsky.deepln.com's password:
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.19.0-50-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.
-------------------------------------------------------------------------------------
-                                ###重要###                                        -
-                                                                                  -  -
   

原文地址:https://blog.csdn.net/Winkyyyyyy/article/details/142444405

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!