Software Environment
Machine a:win7x64 (192.168.8.8):
python2.7 + Fabric Latest
Django
Freesshd (SSH user name: Administrator,nt authentication, the Windows user password is ABC)
Putty (Verify SSH connection)
Machine B:
Linux
Git server
Machine C:
Linux
Ssh
Verify with
------------------------------------------------------
Fab website Tutorial:
Http://docs.fabfile.org/en/1.10/tutorial.html
1, the FAB official website tutorial used a Django project
With no ready-made Django project on hand, I had to use the latest Django official tutorial,
https://docs.djangoproject.com/en/1.8/intro/tutorial01/
One was built first. The Django official tutorial is well written, easy to get started with and easy to run.
Only the FAB website uses the tests.py, needs to write one or two simple testcase
Therefore, in the Fab official website tutorial, all the commands used in the My_app need to be replaced by polls
2. Fab deploy connecting to the local server has encountered a series of problems:
Question 1:
Because the original example does not write env, so will be prompted to connect which host, I entered the localhost, the results of the error:
Low level socket error connecting to host localhost
Troubleshooting Procedures:
(1) This machine uses putty even localhost no problem
(2) Login machine C (Linux),
When an SSH 192.168.8.8 is performed, it attempts to connect with the current user name of machine C, so it cannot succeed
Therefore, the SSH administrator@192.168.8.8 is executed instead, but it is not connected.
Think of maybe a firewall problem, so put Python.exe, fab.exe,freesshd and TCP 22 ports through firewalls,
At this point, the SSH connection on machine C 192.168.8.8,ok,
But on this machine, the FAB code still reports the lower level socket error, the problem still exists
(3)
Lenovo to the previous Web application has also occurred localhost, only 127.0 0.1, or vice versa,
So in the FAB code, the first part adds the env definition, not localhost, but with 127.0.0.1
env.hosts=[' administrator@127.0.0.1:22 ']
Env.user= ' Administrator '
env.password= ' abc '
Problem 1 solved.
Resources:
http://stackoverflow.com/questions/1469431/ Why-am-i-receiving-a-low-level-socket-error-when-using-the-fabric-python-library
Question 2:
Unable to execute command or shell in remote system:failed to execute process
The Windows command could not be executed after the SSH connection on the local computer, reporting the above error
This problem, the predecessors after careful study of the conclusion is that on Windows, the default fab also attempted to execute Bash command, so need to redefine the shell
So in the FAB code, the opening part continues to increase
Env.shell= "CMD/C"
Problem 2 solved.
Resources:
Http://stackoverflow.com/questions/22504784/fabric-cannot-execute-remote-command-on-windows
Http://stackoverflow.com/questions/14863659/paramiko-not-executing-command-or-shell-python
Question 3:
The with CD () statement does not work:
Code_dir= "H:\mydjango"
#code_dir = "/h/mydjango"
With CD (CODE_DIR):
Run ("dir")
It turns out that the list is always C:\windows\system32 content, searched a circle, and didn't find a solution
Had to discard with CD (), to execute directly
Run ("H:" + "&&" + "CD" +code_dir+ "&&" + "dir")
That's where the right stuff is listed.
After that, deploy can log in 127.0.0.1, but execute git clone command, always error ssh problem
Continue to discover, originally under Win7, in the normal way to execute git command, git bash comes with ssh to the ~/.ssh/id_rsa.pub and Id_rsa files, where the pub file was already submitted to the Gitlab server
and SSH login This machine, in fact no longer is the normal way to execute git command, but to the freesshd own small environment, so use is fresshd own with SSH,
However, it seems that freesshd SSH does not read ~/.ssh/id_rsa.pub and Id_rsa files, but its own configuration also has no place to do related configuration, its own configuration directory with only its own private key.
So, I think freesshd seems to be incomplete, or I do not understand the position.
So I had to give up freesshd this road.
Thus, instead of OpenSSH for Windows
Encountered some inexplicable problems: run some commands, the command finally inexplicably added a space (0x20 characters), resulting in command execution failed. (no reason has been uncovered)
A public key can be set in the OpenSSH configuration directory, so log on as putty, perform ssh-t git@gitlab.com, and execute successfully, but run ("Deploy Ssh-t") within Fab git@gitlab.com will fail. (no reason has been uncovered)