Перейти к содержимому

Удаленно запустить сеанс SSH

0

Для выполнения какой-то работы мне нужно открыть сеанс PuTTY на моем ноутбуке в течение нескольких часов, чтобы запустить некоторые сценарии. Тем не менее, я часто в пути и не могу оставить свой ноутбук без подключения к Интернету так долго, чтобы сеанс мог работать без отключения.

Итак, мой вопрос, возможно ли запустить сеанс SSH, который не основан на моем ноутбуке? Спасибо, парни!

93 просмотра
Joe спросил 10 лет назад
J 1

2 ответа

2

You need either tmux or screen. You can find usually both of them on every linux flavour.

These programs build up a layer between the terminal and the remote client. You can detach the client and still everything keeps running because the login shell thinks it's talking to the client while it's connected only to the tmux/screen layer. When you login again, you can reattach to your session you left behind.

Both would require some rtfm but even VERY little knowledge can save life.

Gombai Sándor ответил 10 лет назад
G 3 035
2

Have you looked into GNU Screen ?
https://www.gnu.org/software/screen/

When you SSH from your laptop to the Linux server and start a job/process, normally the job will be killed if your SSH connection drops.

With GNU Screen however, the virtual terminal you were working through will carry on happily if your SSH session ends before you'd like.

It's simple to use, and offers other benefits too !

Try it :
As soon as you've SSHd to your server, enter "screen" (assuming it is installed).
Then run any long-running work script, or command like "top". Then close puTTY.

SSH anew to the server and your job will seem lost, but enter "screen -ls", and you'll see a listing of your disconnected virtual terminal session.

To re-attach to it, enter "screen -r" ... and you should see your script or process still running !

To exit screen, you can just enter "exit" at the command line, and you'll be returned to your usual shell (unless multiple screen windows exist).

To manually detach a screen, enter "screen -d" or type Ctrl-a (control key plus letter "a") then "d".

For help with GNU Screen, while in it, issue Ctrl-a then "?".

Good luck !

robut ответил 10 лет назад
R 103