File: 2011-10-06.ssh_scp_sudo_chroot

package info (click to toggle)
cdist 7.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 9,992 kB
  • sloc: sh: 16,815; python: 9,199; makefile: 344; awk: 261
file content (87 lines) | stat: -rw-r--r-- 2,175 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Commands needed:
   conf/cmd/remote_exec
   conf/cmd/copy

If ! conf/cmd/remote_exec:
   use builtin
If ! conf/cmd/copy:
   use builtin

--------------------------------------------------------------------------------

--cmd-dir?
$__cdist_cmd_dir

--------------------------------------------------------------------------------
   -> Depend on session!

Builtin:
        cdist.exec.run_or_fail(["scp", "-qr", source, 
                                self.remote_user + "@" + 
                                self.target_host + ":" + 
                                destination])

self.remote_prefix = ["ssh", self.remote_user + "@" + self.target_host]

        self.remote_user = remote_user
        self.remote_prefix = remote_prefix

--------------------------------------------------------------------------------
What is in a session?

   base_dir
   target_host

--------------------------------------------------------------------------------
remote_user 
   pseudo-static, can be hardcoded again
--------------------------------------------------------------------------------

Result:

os.environ['__remote_exec'] = ["ssh", "-l", "root" ]

os.environ['__remote_exec'] = ["ssh", "-o", "User=root" ]
os.environ['__remote_copy'] = ["scp", "-o", "User=root" ]


__remote_exec=~/sudossh __remote_copy=... cdist config localhost

~/sudossh hostname $@...
~/sudocopy a hostname:b

~/chrootssh
~/chrootcopy



a)
   3 cmd verzeichnnise: cdist, sudo, chroot
   pro aufruf variable ändern

b)
   1 dir, mit zeug
   pro aufruf variablen ändern


conf/cmd/remote_exec 

args for __remote_exec
   $1 = hostname
   $2 - ...  = stuff to be executed in /bin/sh on remote side
   $2 - $7 = env
   $7 - 12 = cmd


args for __remote_copy
   $1 = file here
   $2 = hostname:destination

--------------------------------------------------------------------------------
There needs to be an easy way to change those cmds!
--------------------------------------------------------------------------------
Env-Passing:
   _a=b test -> test can access $_a
   _a=b test $_a -> $1 = "", because _a is *not* set within the shell
   _a=b; test -> can access $_a
   _a=b; test $_a -> $1 == "b"