Skip to content

Instantly share code, notes, and snippets.

@leetking
Created July 30, 2019 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leetking/0582136b3e5a4f05435373d6e87722b8 to your computer and use it in GitHub Desktop.
Save leetking/0582136b3e5a4f05435373d6e87722b8 to your computer and use it in GitHub Desktop.
:: 使用 ssh 连接到虚拟机内的 ArchLinux 系统
@echo off
: archlinux 是 .ssh/config 里为虚拟机设置的别名
set vm=ArchLinux
if "%1" == "stop" (
echo Save state of %vm% ...
VBoxManage controlvm %vm% savestate
goto QUIT
) else if "%1" == "status" (
VBoxManage list runningvms | findstr %vm%
if errorlevel 1 (
echo vm %vm% stoped
)
goto QUIT
)
VBoxManage list runningvms | findstr %vm% 1> nul 2> nul
if errorlevel 1 (
echo Starting %vm% ...
VBoxManage startvm %vm% --type headless
)
if "%1" == "start" (
goto QUIT
)
: 默认连接到虚拟机
ssh archlinux
:QUIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment