Logon Keys For Z/OS SFTP Client

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
mwdazzo
Posts: 55
Joined: Fri Jan 07, 2011 10:02 am

Logon Keys For Z/OS SFTP Client

Post by mwdazzo »

I am trying to setup logon keys to use SFTP with cozbatch. I have tested using the pw feature and that works fine.

I am following the example from the slide presentation on your web site. Part1 (sshkeygen) of the example works fine, when I get to part2 where you use SFTP on the command line is where I fail. I get the error 'The SSH client cannot be run under OMVS', where am i going wrong? Any help is appreciated. Thanks Matt

One more question about part2 example, are you doing an sftp to the business partner server?

Generating public/private dsa key pair.
Enter file in which to save the key (/u/st1mat/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /u/st1mat/.ssh/id_dsa.
Your public key has been saved in /u/st1mat/.ssh/id_dsa.pub.
The key fingerprint is:
92:4c:c1:ad:bf:08:8c:1d:02:ca:67:f8:61:0c:26:b9 ST1MAT@MVSTECH
ST1MAT:/u/st1mat/.ssh: >sftp ST1MAT@MVSTECH
Connecting to MVSTECH...
FOTS1252 The SSH client cannot be run under OMVS.
FOTS0841 Connection closed
ST1MAT:/u/st1mat/.ssh: >sftp 27.60.1.2
Connecting to 27.60.1.2...
FOTS1252 The SSH client cannot be run under OMVS.
FOTS0841 Connection closed
ST1MAT:/u/st1mat/.ssh: >
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Matt,

- Here's a section from the Co:Z SFTP User's Guide that might help:
http://dovetail.com/docs/sftp/auth.html#auth-sshkeys

- You might also want to try using ssh keys stored in a SAF(RACF) certificate, which has many advantages.
See: http://dovetail.com/docs/sftp/client.ht ... batch_cert and http://dovetail.com/docs/coz/auth.html
mwdazzo
Posts: 55
Joined: Fri Jan 07, 2011 10:02 am

Logon Keys For Z/OS SFTP Client

Post by mwdazzo »

I have opted to use a racf self signed cert for testing authentication on our sftp server. I created the cert and exported it to a file. I am now trying to move the public part to the target system. Seems I can not connect as the documentation shows. I am using a zos shell over telnet then trying to connect to the ssh server. A screen print is below, any help is appreciated. tks Matt



ST1MAT:/u/st1mat: >sftp -oPort=22 mdazzo@27.60.1.2
Connecting to 27.60.1.2...
Password:
FOTS0858 Couldn't canonicalise: No such file or directory
FOTS0838 Need cwd
ST1MAT:/u/st1mat: >FOTS0858 Couldn't canonicalise: No such file or directory
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

First, you are using IBM's sftp client and not CO:Z sftp (the cozsftp command).

But the first thing to try is just to connect with an interative ssh shell and get a trace:

ssh -vvv -oPort=22 mdazzo@27.60.1.2

Post that trace, and we'll take a look.

Also, you didn't say how your were telling sftp to use your key ring (the IdentityKeyRing option). Did you put this in the ~/.ssh/zos_user_ssh_config file?
mwdazzo
Posts: 55
Joined: Fri Jan 07, 2011 10:02 am

Logon Keys For Z/OS SFTP Client

Post by mwdazzo »

Here is the trace info,



debug1: Connecting to 27.60.1.2 [27.60.1.2] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug3: timeout: 14999 ms remain after connect
debug1: permanently_set_uid: 0/1
debug3: zsshGetpw: passwd name=ST1MAT, uid=0, gid=1, dir=/u/st1mat, shell=/bin/sh
debug1: identity file /u/st1mat/.ssh/id_rsa type -1
debug3: Not a RSA1 key file /u/st1mat/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /u/st1mat/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5
debug1: match: OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.0
debug2: fd 3 setting O_NONBLOCK
debug3: RNG is ready, skipping seeding
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 132/256
debug2: bits set: 519/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /u/st1mat/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host '27.60.1.2' is known and matches the RSA host key.
debug1: Found key in /u/st1mat/.ssh/known_hosts:1
debug2: bits set: 497/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /u/st1mat/.ssh/id_rsa (0)
debug2: key: /u/st1mat/.ssh/id_dsa (1210B0B0)
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug3: start over, passed a different list publickey,password,keyboard-interactive,hostbased
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /u/st1mat/.ssh/id_rsa
debug3: no such identity: /u/st1mat/.ssh/id_rsa
debug1: Offering public key: /u/st1mat/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:
debug3: packet_send2: adding 32 (len 22 padlen 10 extra_pad 64)
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 0
debug3: packet_send2: adding 48 (len 10 padlen 6 extra_pad 64)
debug1: Authentication succeeded (keyboard-interactive).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 0
debug3: tty_make_modes: ospeed 9600
debug3: tty_make_modes: ispeed 9600
debug3: tty_make_modes: 1 3
debug3: tty_make_modes: 2 22
debug3: tty_make_modes: 3 8
debug3: tty_make_modes: 4 21
debug3: tty_make_modes: 5 4
debug3: tty_make_modes: 6 10
debug3: tty_make_modes: 8 17
debug3: tty_make_modes: 9 19
debug3: tty_make_modes: 10 26
debug3: tty_make_modes: 30 0
debug3: tty_make_modes: 31 0
debug3: tty_make_modes: 32 0
debug3: tty_make_modes: 33 0
debug3: tty_make_modes: 34 0
debug3: tty_make_modes: 35 0
debug3: tty_make_modes: 36 1
debug3: tty_make_modes: 37 0
debug3: tty_make_modes: 38 1
debug3: tty_make_modes: 39 0
debug3: tty_make_modes: 40 0
debug3: tty_make_modes: 50 1
debug3: tty_make_modes: 51 1
debug3: tty_make_modes: 52 0
debug3: tty_make_modes: 53 1
debug3: tty_make_modes: 54 1
debug3: tty_make_modes: 55 1
debug3: tty_make_modes: 56 1
debug3: tty_make_modes: 57 0
debug3: tty_make_modes: 58 0
debug3: tty_make_modes: 59 0
debug3: tty_make_modes: 70 1
debug3: tty_make_modes: 71 0
debug3: tty_make_modes: 72 1
debug3: tty_make_modes: 73 0
debug3: tty_make_modes: 74 0
debug3: tty_make_modes: 75 1
debug3: tty_make_modes: 90 1
debug3: tty_make_modes: 91 1
debug3: tty_make_modes: 92 0
debug3: tty_make_modes: 93 0
debug2: channel 0: request shell confirm 0
debug2: fd 3 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 65536
Last successful login for mdazzo: Wed Jan 19 10:40:00 EST5EDT 2011 on tty
Last unsuccessful login for mdazzo: Wed Apr 14 15:07:56 EST5EDT 2010
Last login: Wed Jan 19 10:40:00 2011 from mdazzoxp.classi
(c)Copyright 1983-2000 Hewlett-Packard Co., All Rights Reserved.
(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California
(c)Copyright 1980, 1984, 1986 Novell, Inc.
(c)Copyright 1986-1992 Sun Microsystems, Inc.
(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology
(c)Copyright 1989-1993 The Open Software Foundation, Inc.
(c)Copyright 1986 Digital Equipment Corp.
(c)Copyright 1990 Motorola, Inc.
(c)Copyright 1990, 1991, 1992 Cornell University
(c)Copyright 1989-1991 The University of Maryland
(c)Copyright 1988 Carnegie Mellon University
(c)Copyright 1991-2000 Mentat Inc.
(c)Copyright 1996 Morning Star Technologies, Inc.
(c)Copyright 1996 Progressive Systems, Inc.
(c)Copyright 1991-2000 Isogon Corporation, All Rights Reserved.


RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the U.S. Government is subject to
restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause in DFARS 252.227-7013.

Hewlett-Packard Company
3000 Hanover Street
Palo Alto, CA 94304 U.S.A.

Rights for non-DOD U.S. Government Departments and Agencies are as set
forth in FAR 52.227-19(c)(1,2).
# # ###### ####### # # ###
# # # # # # # # ## # #
# # # # # # # # # # #
####### ###### # # # # # #
# # # # ####### # # #
# # # # # # # #
# # # # # ##### ###

hp1dev:mdazzo:/home/mdazzo:
dovetail
Site Admin
Posts: 2025
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

So, it works using ssh. Can you sign into this server with *any* sftp client, even interactively with a password? I doubt it.

This is because I believe that your server is writing text "Welcome messages" to stdout when you sign in, even when connecting into ssh with non-interactive shell. Depending on the user's default shell, this could be done in various profile or rc files on the server or for this user's account.

Its OK if messages are written to stderr, since these won't interfere with the sftp subsystem, but if the server's login process writes messages to stdout then you won't be able to connect with sftp.

To test this, see if the following results in an empty file:

Code: Select all

ssh -oPort=22 user@host sleep 2 > file.out
If it doesn't, then the server's login process for this user is writing messages to stdout, which will corrupt *any* sftp client.

To get around this, find where these messages are being written, and bracket them in something like (which vary depending on what kind of shell your system using):

if test -t 0 ; then
echo some annoying message
...
fi
Post Reply