可能重复:
在关闭SSH客户端后阻止后台进程停止
我有一个需要很多时间才能完成的程序.它在ssh上以root身份运行.
我希望它在我退出后继续运行,这是否可能,我将如何实现这一目标?
我正在远程主机上执行通过无密码SSH连接的脚本.我想设置一个超时,这样如果远程主机花了无限的时间来运行,我想从ssh会话中走出来继续我的sh脚本中的其他行.
有什么想法怎么做?
我按照git指南但在尝试连接到github时遇到了这个奇怪的问题:
$ ssh -v git@github.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Documents and Settings/mugues/.ssh/config
debug1: Applying options for github.com
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: connect to address 207.97.227.239 port 22: Attempt to connect timed out without establishing a connection
ssh: connect to host github.com port 22: Bad file number
Run Code Online (Sandbox Code Playgroud)
这是我在.ssh下的配置文件
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile "C:\Documents and Settings\mugues\.ssh\id_rsa"
TCPKeepAlive yes
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
任何的想法?
在Python中scp文件的最pythonic方法是什么?我所知道的唯一途径是
os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) )
Run Code Online (Sandbox Code Playgroud)
这是一个hack,并且在类似Linux的系统之外不起作用,并且需要Pexpect模块的帮助以避免密码提示,除非您已经将无密码SSH设置到远程主机.
我知道Twisted的conch,但我宁愿避免通过低级ssh模块自己实现scp.
我知道paramiko,一个支持ssh和sftp的Python模块; 但它不支持scp.
背景:我正在连接到不支持sftp但支持ssh/scp的路由器,所以sftp不是一个选项.
编辑:这是如何使用SCP或SSH将文件复制到Python中的远程服务器?. 但是,这个问题没有给出一个scp特定的答案来处理python中的键.我希望有一种运行代码的方式
import scp
client = scp.Client(host=host, user=user, keyfile=keyfile)
# or
client = scp.Client(host=host, user=user)
client.use_system_keys()
# or
client = scp.Client(host=host, user=user, password=password)
# and then
client.transfer('/etc/local/filename', '/etc/remote/filename')
Run Code Online (Sandbox Code Playgroud) 当我ssh到一台机器时,有时我会收到此错误警告,并提示说"是"或"否".从自动ssh到其他计算机的脚本运行时,这会导致一些问题.
警告信息:
The authenticity of host '<host>' can't be established.
ECDSA key fingerprint is SHA256:TER0dEslggzS/BROmiE/s70WqcYy6bk52fs+MLTIptM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'pc' (ECDSA) to the list of known hosts.
Run Code Online (Sandbox Code Playgroud)
有没有办法自动说"是"或忽略这个?
我如何重新连接到一个独立的mosh会话或以其他方式摆脱
Mosh: You have a detached Mosh session on this server (mosh [XXXX]).
Run Code Online (Sandbox Code Playgroud)
也就是什么是mosh相当于
screen -D -R
Run Code Online (Sandbox Code Playgroud)
或者可能
screen -wipe
Run Code Online (Sandbox Code Playgroud)
此外,在文档中可以找到这个答案的位置?
我试图在连接到ssh服务器后找到UNIX或bash命令来运行命令.例如:
ssh name@ip "tmux list-sessions"
Run Code Online (Sandbox Code Playgroud)
上面的代码工作,它列出了会话,但然后立即断开连接.将它放在服务器端的sshrc中可以正常工作,但我需要能够在客户端输入它.我希望能够运行命令,登录,打开窗口,然后运行我设置的命令.我试过了
[command] | ssh name@ip
ssh name@ip [command]
ssh name@ip "[command]"
ssh -t name@ip [command]
Run Code Online (Sandbox Code Playgroud) 我想重现Vagrant如何使用ssh命令在shell脚本中记录到我的VM的方式,因此我为我的Vagrant实例创建了一个别名.
使用常规ssh命令访问它的命令语法是什么?
我在一个SSH会话中运行了Screen.终端冻结了.重新启动终端后,该屏幕会话仍然认为它已附加.也许是.也许我真的不知道这意味着什么.
我想通过全新的SSH登录来附加屏幕会话.我不想杀死那个屏幕会话,因为那里发生了重要的事情.:)
我认为我有的选项(我都不知道如何解决):
ssh ×10
linux ×3
bash ×2
shell ×2
command-line ×1
fingerprint ×1
git ×1
github ×1
gnu-screen ×1
ip-address ×1
networking ×1
paramiko ×1
python ×1
scp ×1
ssh-keys ×1
terminal ×1
timeout ×1
unix ×1
vagrant ×1