Get rid of Pseudo-terminal message when you use ssh with here document

When I send multiple commands over ssh to a Linux or ESXi host using here document, I get this message:

Pseudo-terminal will not be allocated because stdin is not a terminal.

For example:

    $ ssh -q root@esxi.local.example.com  <<EOF
    > date
    > hostname
    > EOF
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    Sun Aug 14 06:01:26 UTC 2016
    esxi.local.example.com

Continue reading “Get rid of Pseudo-terminal message when you use ssh with here document”

Get rid of Pseudo-terminal message when you use ssh with here document

Collecting directly connected switch ports ID from multiple ESXi hosts

We are going to add vlan to a cluster. We need to know what are the switch ports for each Guest vmnic in each hosts so that we can ask the network team to trunk the new vlan.

This little script collects the switch ports information obtained using CDP. The list of hosts is stored in a text file list.

    for i in `cat list`
    do
    ssh -q -T root@$i <<EOF
    hostname
    vim-cmd hostsvc/net/query_networkhint --pnic-name=vmnicX  | grep -E  'devId|portId'
    vim-cmd hostsvc/net/query_networkhint --pnic-name=vmnicY  | grep -E  'devId|portId'
    echo
    EOF
    done

In this example, vmnicX and vmnicY are used for Guest network. If you don't have ssh keys setup, you can use sshpass.

    host1.esx.example.com
             devId = "SwitchA",
             portId = "Ethernet110/1/2",
             devId = "SwitchB",
             portId = "Ethernet110/1/2",

    host2.esx.example.com
             devId = "SwitchA",
             portId = "Ethernet110/1/4",
             devId = "SwitchB",
             portId = "Ethernet110/1/4",

    host3.esx.example.com
             devId = "SwitchA",
             portId = "Ethernet110/1/6",
             devId = "SwitchB",
             portId = "Ethernet110/1/6",

    ... and so on
Collecting directly connected switch ports ID from multiple ESXi hosts

User cannot ssh to server, Permission denied

A user is unable to ssh to a Linux box. There is no prompt for password and directly drops to a “Permission denied” error.

ssh user@linux
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

The user uses password authentication and does not use keys. Inspecting sshd_config on the server, password authentication is disabled for this user. This is the reason why the user was unable to login.

A snippet of sshd_config with the settings and explanation.

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       ForceCommand cvs server
Match User user
        PasswordAuthentication no
User cannot ssh to server, Permission denied