// GetSSH returns SSH keys to access the virtual machine
341270
func (vm *VM) GetSSH(options ssh.Options) (ssh.Client, error) {

	ips, err := util.GetVMIPs(vm, options)
	if err != nil {
		return nil, err
	}

	client := &ssh.SSHClient{
		Creds:   &vm.SSHCreds,
		IP:      ips[0], // public IP
		Options: options,
		Port:    22,
	}
	if err := client.WaitForSSH(SSHTimeout); err != nil {
		return nil, err
	}

	return client, nil

}
394988
func (vm *VM) GetState() (string, error) {
	stdout, stderr, err := runner.Run("list")
	if err != nil {
		return "", err
	}
	if stderr != "" {
		return "", fmt.Errorf("Failed to get state using the vmrun utility: %s", stderr)
	}

	if strings.Contains(stdout, vm.Dst) {
		return lvm.VMRunning, nil
	}

	// Maybe vm.Dst is a symlink?
	p, err := filepath.EvalSymlinks(vm.Dst)
	if err != nil {
		return "", err
	}

	absp, err := filepath.Abs(p)
	if err != nil {
		return "", err
	}

	if strings.Contains(stdout, absp) {
		return lvm.VMRunning, nil
	}

	// Originally reported these as VMHalted, but for our purposes it was better
	// to list them as VMSuspended so that we did not assume they would start up
	// in an initial state.
	return lvm.VMSuspended, nil
}
1357646
func (c *FleetClient) SSH(name string) error {
	sshClient, _, err := c.sshConnect(name)
	if err != nil {
		return err
	}

	defer sshClient.Close()
	err = ssh.Shell(sshClient)
	return err
}
1050181
func (state *UserState) PasswordHash(username string) (string, error) {
	return state.users.Get(username, "password")
}
933595
func (m *Cluster) GetHosts() []*address.Address {
	if m != nil {
		return m.Hosts
	}
	return nil
}
1070488
func (c *CommitFile) GetSHA() string {
	if c == nil || c.SHA == nil {
		return ""
	}
	return *c.SHA
}
1079802
func GetHost(r *http.Request) string {
	h := r.URL.Host
	if h == "" {
		h = r.Host
	}
	return h
}
155337
func (b *Blob) GetSHA() string {
	if b == nil || b.SHA == nil {
		return ""
	}
	return *b.SHA
}
887159
func (c *Client) GetSSHKeys() (keys []SSHKey, err error) {
	var keyMap map[string]SSHKey
	if err := c.get(`sshkey/list`, &keyMap); err != nil {
		return nil, err
	}

	for _, key := range keyMap {
		keys = append(keys, key)
	}
	sort.Sort(sshkeys(keys))
	return keys, nil
}
424702
func Get() (agent.Agent, error) {
	agentConn, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
	return agent.NewClient(agentConn), err
}
1083216
func (n *NeutrinoChainConn) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
	return n.p2pNode.GetBlockHash(blockHeight)
}
650456
func (c *FakeSSHCredentials) Get(name string, options v1.GetOptions) (result *v1alpha1.SSHCredential, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(sshcredentialsResource, c.ns, name), &v1alpha1.SSHCredential{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.SSHCredential), err
}
656601
func (m *MockCryptoSuite) GetHash(opts core.HashOpts) (hash.Hash, error) {
	return sha256.New(), nil
}
1246407
func (p *requiredProperty) getHashKey() ([]byte, error) {
	datums := make([]types.Datum, 0, len(p.props)*3+1)
	datums = append(datums, types.NewDatum(p.sortKeyLen))
	for _, c := range p.props {
		datums = append(datums, types.NewDatum(c.desc), types.NewDatum(c.col.FromID), types.NewDatum(c.col.Index))
	}
	bytes, err := codec.EncodeValue(nil, datums...)
	return bytes, errors.Trace(err)
}
333593
func getShell(c *container.Config, os string) []string {
	if 0 == len(c.Shell) {
		return append([]string{}, defaultShellForOS(os)[:]...)
	}
	return append([]string{}, c.Shell[:]...)
}
767156
func (vm *VM) GetState() (string, error) {
	if vm.MockGetState != nil {
		return vm.MockGetState()
	}
	return "", lvm.ErrNotImplemented
}
781013
func checkSSH() error {
	const ERROR_SERVICE_DOES_NOT_EXIST syscall.Errno = 0x424

	const msgFmt = "%s service not running and start type is disabled.  " +
		"To enable ssh on Windows you must run the enable_ssh job from the " +
		"windows-utilities-release."

	m, err := mgr.Connect()
	if err != nil {
		return fmt.Errorf("opening service control manager: %s", err)
	}
	defer m.Disconnect()

	sshd, err := m.OpenService("sshd")
	if err != nil {
		if err == ERROR_SERVICE_DOES_NOT_EXIST {
			return errors.New("sshd is not installed")
		}
		return fmt.Errorf("opening service sshd: %s", err)
	}
	defer sshd.Close()

	st, err := sshd.Query()
	if err != nil {
		return fmt.Errorf("querying status of service (sshd): %s", err)
	}
	if st.State != svc.Running {
		if serviceDisabled(sshd) {
			return fmt.Errorf(msgFmt, "sshd")
		}
		return errors.New("sshd service is not running")
	}

	return nil
}