Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

Thursday, August 1, 2013

X11 forwarding request failed on channel 0

I was testing X11 stuff under a SmartOS zone, using the latest pkgsrc-2013Q2, but I got the following error doing an ssh

ssh dest.server -l root -X

X11 forwarding request failed on channel 0


The solution, as suggested by jperkin, is to add this line

XAuthLocation /opt/local/bin/xauth

to

/etc/ssh/sshd_config

and restart ssh.

Or you can disable Sun_SSH_1.5 service and install openssh.

Wednesday, July 31, 2013

bash while loop, function and ssh

Yesterday I struggled an entire morning with a while loop inside a bash script.
The loop ended even if there was a lot of work to do.
And the while loop ended only when I was calling a function inside another function.

The function contained an ssh call to a remote host to get a result.
Such ssh connection, opening a shell on the remote host, maybe killed my while environment?

The solution:

remote() {
  echo -e "Checking if it is the first time we zfs send to remote $1"
 
  ssh $sshparam zfs list $1 </dev/null &>/dev/null 
 
  EL=$?
  if [ $EL -eq 0 ]
  then
    return 1
  else
    return 0
  fi
} 

</dev/null &>/dev/null 

Friday, February 15, 2013

linux scp and umask

I use CentOS 5.x
The problem is that if I use scp or sftp to copy a file on such CentOS server, the umask is not taken in consideration.
Behavior of scp and sftp is different.

Btw, a solution is to use openssh 5, but I don't like to alter the distribution, since CentOS 5 install openssh 4.

Using google I've found different solution (pam? etc.) but no one works for me.

So, a way to make what I want is:

For sftp

vi /etc/ssh/sshd_config
...
# override default of no subsystems
# Subsystem       sftp    /usr/libexec/openssh/sftp-server
Subsystem sftp /bin/sh -c 'umask 0002; /usr/libexec/openssh/sftp-server'

and restart sshd


And for scp

vi /home/myuser/.bashrc




adding (0002 or what you want)

umask 0002

Monday, August 13, 2012

Openindiana: Too many authentication failures

From an Openindiana host, and connecting to some Linux hosts, often I receive this error from the ssh client

Received disconnect from 10.11.12.13: 2: Too many authentication failures for yourfuckingusername

The fact is that ssh try to first authenticate using keys, and if you have many keys he tries every one of them, so... maybe the server or the Openindiana (I've never seen this problem on Mac OS X, in example) ssh command exit after two or three failed keys authentication.

The solution is to use PubkeyAuthentication options in the ssh command

ssh -oPubkeyAuthentication=no 10.11.12.13

Or to edit ~/.ssh/conf file

Host 10.11.12.13
    PubkeyAuthentication=no