MCPcopy Index your code
hub / github.com/smallstep/cli / NewShell

Function NewShell

internal/sshutil/shell.go:111–144  ·  view source on GitHub ↗

NewShell initializes a new shell to the given address.

(user, address string, opts ...ShellOption)

Source from the content-addressed store, hash-verified

109
110// NewShell initializes a new shell to the given address.
111func NewShell(user, address string, opts ...ShellOption) (*Shell, error) {
112 address = formatAddress(address)
113
114 // Use known_host as HostKeyCallback
115 knownHosts, err := knownhosts.New(filepath.Join(step.Home(), ".ssh", "known_hosts"))
116 if err != nil {
117 return nil, errors.Wrap(err, "error reading known_hosts")
118 }
119
120 shell := &Shell{
121 user: user,
122 address: address,
123 }
124 if err := shell.apply(opts); err != nil {
125 return nil, err
126 }
127
128 if len(shell.authMethods) == 0 {
129 if err := withDefaultAuthMethod()(shell); err != nil {
130 return nil, err
131 }
132 }
133 if shell.dialer == nil {
134 if err := withDefaultDialer(user, address)(shell); err != nil {
135 return nil, err
136 }
137 }
138
139 if shell.client, err = shell.dialer(knownHosts); err != nil {
140 return nil, err
141 }
142
143 return shell, nil
144}
145
146func (s *Shell) apply(opts []ShellOption) error {
147 for _, fn := range opts {

Callers

nothing calls this directly

Calls 4

applyMethod · 0.95
formatAddressFunction · 0.85
withDefaultAuthMethodFunction · 0.85
withDefaultDialerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…