I'm trying to set sftpuser restricted by ChrootDirectory on AIX7.1. But it's not working and shown "connection to localhost closed by remote host"
Now, I configurated in /etc/ssh/sshd_config
Match User testuser
ChrootDirectory /Share
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
The /Share owner by root user and permission is 755 but it's still not working and show debug as below.
sftp -vvv testuser#localhost
OpenSSH_8.1p1, OpenSSL 1.0.2u 20 Dec 2019
debug1: Authentication succeeded (password).
Authenticated to localhost ([127.0.0.1]:22).
debug2: fd 5 setting O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions#openssh.com
debug3: send packet: type 80
debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
Connection to localhost closed by remote host.
Transferred: sent 2256, received 2228 bytes, in 0.0 seconds
Bytes per second: sent 270661.7, received 267302.4
debug1: Exit status -1
Connection closed
How can I solve it? Thanks in advance for your help.
Related
We set up a remoteforward to proxy a webhook to our local dev machine. Everything works fine on Mac, but when we do the same thing on Windows 10 we get a 502 Bad Gateway.
Is there something I'm missing?
We've set GateWayPorts yes and PermitTunnel yes in C:\ProgramData\ssh\sshd_config
.ssh\config file:
Host webhook
HostName ww.xx.yy.zz
IdentityFile C:\Users\...\.ssh\key.pem
User blah-user
RemoteForward 25003 localhost:25007
GatewayPorts yes
output from ssh -vvv webhook
https://aws.amazon.com/amazon-linux-2/
No packages needed for security; 2 packages available
Run "sudo yum update" to apply all updates.
[blah-user#ip-ww-xx-yy-zz ~]$ debug3: receive packet: type 90
debug1: client_input_channel_open: ctype forwarded-tcpip rchan 3 win 2097152 max 32768
debug1: client_request_forwarded_tcpip: listen localhost port 25003, originator 127.0.0.1 port 46568
debug2: fd 7 setting O_NONBLOCK
debug3: socketio_getsockopt - ERROR:10022
debug1: getsockopt TCP_NODELAY: Invalid argument
debug1: connect_next: host localhost ([::1]:25007) in progress, fd=7
debug3: fd 7 is O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 1: new [127.0.0.1]
debug1: confirm forwarded-tcpip
debug3: channel 1: waiting for connection
debug3: finish_connect - ERROR: async io completed with error: 10061, io:00000224831A7210
debug1: channel 1: connected to localhost port 25007
debug3: send packet: type 91
debug3: recv - from CB ERROR:10061, io:00000224831A7210
debug2: channel 1: read<=0 rfd 7 len 4294967295
debug2: channel 1: read failed
debug2: chan_shutdown_read: channel 1: (i0 o0 sock 7 wfd 7 efd -1 [closed])
debug3: socketio_shutdown - ERROR:10057
debug2: channel 1: input open -> drain
debug2: channel 1: ibuf empty
debug2: channel 1: send eof
debug3: send packet: type 96
debug2: channel 1: input drain -> closed
debug3: ERROR:10061, io:00000224831A7210
debug2: channel 1: write failed
debug2: chan_shutdown_write: channel 1: (i3 o0 sock 7 wfd 7 efd -1 [closed])
debug3: socketio_shutdown - ERROR:10057
debug2: chan_shutdown_write: channel 1: shutdown() failed for fd 7 [i3 o0]: The socket is not connected
debug2: channel 1: output open -> closed
debug2: channel 1: send close
debug3: send packet: type 97
debug3: channel 1: will not send data after close
debug3: channel 1: will not send data after close
debug3: receive packet: type 96
debug2: channel 1: rcvd eof
debug3: receive packet: type 97
debug2: channel 1: rcvd close
debug3: channel 1: will not send data after close
debug2: channel 1: is dead
debug2: channel 1: garbage collecting
debug1: channel 1: free: 127.0.0.1, nchannels 2
debug3: channel 1: status: The following connections are open:
#0 client-session (t4 r2 i0/0 o0/0 e[write]/0 fd 4/5/6 sock -1 cc -1)
#1 127.0.0.1 (t4 r3 i3/0 o3/0 e[closed]/0 fd 7/7/-1 sock 7 cc -1)
The proxy works, as the exact same config on Mac works like a champ. Tried to turn the firewall off completely, but that didn't change anything.
I hope to find the answer to the question which is bothering me for the past couple of days - I have read a lot of threads, helpers, and publications, and do not seem to find a solution.
I am a bit new with SSH.
The problem is as follows:
I cannot get/install/refresh the modules belonging to my project, when using go get or go mod tidy commands,
while git clone of the same repo via SSH in any of the terminals or via TortoiseGit are working fine,
i.e. I can clone, but I cannot build.
getting a module fails the following way (personal data obfuscated):
example.com/hello/PROJECTS/src/git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources tested by
example.com/hello/PROJECTS/src/git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources.test imports
git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources/vm_specific: module git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources/vm_specific: git ls-remote -q origin in C:\GO\PROJECTS\pkg\mod\cache\vcs\a5d519aeafc0ac08e2b20d7c8a6a8b2cea11cda88cb058cf2ebcc079d07b260a: exit status 128:
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> 'C:\\Users\\<username>/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> 'C:\\Users\\<username>/.ssh/known_hosts2'
debug2: resolving "git.<orgname>.com" port <port>
debug3: resolve_host: lookup git.<orgname>.com:<port>
debug3: ssh_connect_direct: entering
debug1: Connecting to git.<orgname>.com [10.XXX.X.XX] port <port>.
debug1: Connection established.
...
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.9
debug1: Remote protocol version 2.0, remote software version APACHE-SSHD-2.4.0
debug1: compat_banner: no match: APACHE-SSHD-2.4.0
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to git.<orgname>.com:<port> as 'git'
...
debug1: Authentications that can continue: publickey
...
debug3: send packet: type 50
debug3: receive packet: type 52
Authenticated to git.<orgname>.com ([10.XXX.X.XX]:<port>) using "publickey".
...
debug1: Sending command: git-upload-pack '/scm/<reponame>/<subreponame>.git'
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd ext data 106
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug2: chan_shutdown_read: channel 0: (i0 o1 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: obuf_empty delayed efd 6/(106)
debug2: channel 0: written 106 to efd 6
Repository not found
The requested repository does not exist, or you do not have permission to access it.
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: chan_shutdown_write: channel 0: (i3 o1 sock -1 wfd 5 efd 6 [write])
debug2: channel 0: output drain -> closed
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1 io 0x00/0x08)
debug3: send packet: type 1
Transferred: sent 3268, received 2200 bytes, in 0.2 seconds
Bytes per second: sent 15169.6, received 10212.1
debug1: Exit status 1
If a fuller log is needed I can upload it somewhere.
last rows of ssh -T(vvv set as default) git#git.<orgname>.com:
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to git.<orgname>.com ([10.XXX.X.XX]:<port>).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: filesystem full
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: set_sock_tos: set socket 3 IP_TOS 0x08
debug2: client_session2_setup: id 0
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug3: receive packet: type 100
debug2: channel_input_status_confirm: type 100 id 0
shell request failed on channel 0
I am using a public key deriving from a key generated by ssh-keygen of OpenSSH - it is freshly generated and is added to my Git profile.
git clone is thus working fine which is driving me insane already.
I already have the most part of the modules which fail to be checked in the remote private repo, which is even crazier.
I dislike this part, which most probably means that I have issues with my certificate -
Authenticated to git..com ([10.XXX.X.XX]:) using
"publickey".
and this part, as OpenSSH on AIX requests PKCS12 support by default when EFS is enabled and non-AIX systems may reject these PKCS12 requests.
debug2: channel 0: obuf_empty delayed efd 6/(106)
debug2: channel 0: written 106 to efd 6
See changes in my config below.
My environment:
Win10 Enterprise
Git version - 2.31.1.windows.1
I usually clone via TortoiseGit 2.13.0.1
SSH client being used within CMD/Powershell - OpenSSH_for_Windows_8.9, installed manually
go env: (personal data obfuscated)
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\<username>\AppData\Local\go-build
set GOENV=C:\Users\<username>\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Program Files\Go\pkg\mod
set GONOPROXY=*.<orgname>.com;git.<orgname>.com/users/<username>
set GONOSUMDB=*.<orgname>.com;git.<orgname>.com/users/<username>
set GOOS=windows
set GOPATH=C:\Program Files\Go
set GOPRIVATE=*.<orgname>.com;git.<orgname>.com/users/<username>
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\USER~1.NAM\AppData\Local\Temp\go-build1143995380=/tmp/go-build -gno-record-gcc-switches
My SSH config:
# GITHUB FOR SRC
Host git.<orgname>.com
ServerAliveInterval 600
TCPKeepAlive yes
IPQoS throughput
AddKeysToAgent yes
HostName git.<orgname>.com
Port <port>
User <username>
PreferredAuthentications publickey
IdentityFile C:\Users\<username>\.ssh\git_rsa
#IdentityFile ~/.ssh/git_rsa
PubkeyAcceptedKeyTypes +ssh-rsa
#ForwardAgent no
#AllowPKCS12KeystoreAutoOpen no
LogLevel DEBUG3
The certificate was previously added to the agent, but I have specified it here to be sure, and the correct certificate seems to be taken for authentication according to the log.
It does not have a passphrase.
I do not have totally unknown entries in my known-hosts, and the correct entry judging by a certificate timestamp is being used.
I found that the PKCS12 requests can be disabled by AllowPKCS12KeystoreAutoOpen set to no, but it is being marked as a bad option -
C:\GO\PROJECTS\src\git.<orgname>.com\<reponame>\<subreponame>>go get git.<orgname>.com/<name>/go-service/log
go: module git.<orgname>.com/<name>/go-service/log: git ls-remote -q origin in C:\GO\PROJECTS\pkg\mod\cache\vcs\d0d607237eeba0d1c9d5ce996ed36c0f3746b2c8f94b538ace2d3f2a9476839e: exit status 128:
C:\\Users\\<username>/.ssh/config: line 15: Bad configuration option: allowpkcs12keystoreautoopen
C:\\Users\\<username>/.ssh/config: terminating, 1 bad configuration options
GIT configs:
global:
[user]
name = <username>
email = <usrname>#<orgname>.com
[url "ssh://git#git.<orgname>.com:<port>/"]
insteadOf = https://git.<orgname>.com
system:
[url "ssh://git#git.<orgname>.com:<port>/"]
insteadOf = https://git.<orgname>.com/
git remote -v:
origin ssh://git#git.<orgname>.com:<port>/~<username>/<subreponame>.git (fetch)
origin ssh://git#git.<orgname>.com:<port>/~<username>/<subreponame>.git (push)
the same I use for cloning,
repo config:
[remote "origin"]
url = ssh://git#git.<orgname>.com:<port>/~<username>/<subreponame>.git
fetch = +refs/heads/*:refs/remotes/origin/*
I tried both ssh:// and git#git... and it did not help.
module config (set automatically), however:
[remote "origin"]
url = https://git.<orgname>.com/scm/<reponame>/<subreponame>.git
fetch = +refs/heads/*:refs/remotes/origin/*
I am out of ideas at this moment.
I'd recommend not to use go get with private repositories. This command caches repositories at pkg.go.dev and thus exposes them to the world. I was so embarrassed to find our private development published openly there.
I deploy my private dependencies in the file system manually and specify the dependency in go.mod using replace:
require your.server/your/package 1.2.3
replace your.server/your/package 1.2.3 => /path/to/local/your/package
That was an issue with repository - it was not really made to work with dependencies, and was not meant to work with modules and module-related requests. C'est la vie, but at least I've learned a lot about SSH and GIT interaction.
I'm trying to implement SSH server which acts as SCP sink (without calling external scp command) in GO.
I've ended up in partially working code:
https://gist.github.com/Seitanas/ad02158e8d5d2acedd9e7973ae44c77c.
The problem is that when I try to scp file to this service, local scp client copies data correctly but returns 1.
I think something happens at channel close. Maybe I'm missing something inside SCP protocol?
I'm guessing that ssh returns -1 and then scp exits with 1
Testing results:
echo "contents"> test.txt
scp -v -P2222 test.txt foo#127.0.0.1:/
Executing: program /usr/bin/ssh host 127.0.0.1, user foo, command scp -v -t /
...
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password
debug1: Next authentication method: password
foo#127.0.0.1's password:
debug1: Authentication succeeded (password).
Authenticated to 127.0.0.1 ([127.0.0.1]:2222).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_TERMINAL_VERSION = 3.4.12
debug1: Sending env LC_CTYPE = en_US.UTF-8
debug1: Sending env LC_TERMINAL = iTerm2
debug1: Sending command: scp -v -t /
Sending file modes: C0644 9 test.txt
test.txt 0% 0 0.0KB/s --:-- ETAdebug1: channel 0: free: client-session, nchannels 1
test.txt 100% 9 21.4KB/s 00:00
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 2032, received 1116 bytes, in 0.0 seconds
Bytes per second: sent 1245098.0, received 683823.5
debug1: Exit status -1
echo $?
1
Output from go code:
go run test.go
2022/02/15 17:17:21 Command: C
2022/02/15 17:17:21 File info: 0644 9 test.txt
2022/02/15 17:17:21 File size: 9
2022/02/15 17:17:21 Content: contents
Thank you for any ideas.
Right, I've found what the problem is.
I've forgot that I'm simulating SCP binary ant server side, so i need to simulate its exit code also.
So I've added additional line at the end:
channel.SendRequest("exit-status", false, []byte{0, 0, 0, 0})
This will send exit 0 status via channel.
Without it SCP at client side was waiting for remote transfer to finish, but socket was closing right after transfer without exit code.
Now everything works as expected:
debug1: Sending command: scp -v -t /
Sending file modes: C0644 9 test.txt
test.txt 0% 0 0.0KB/s --:-- ETAdebug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
test.txt 100% 9 14.1KB/s 00:00
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 2152, received 1172 bytes, in 0.0 seconds
Bytes per second: sent 1391979.3, received 758085.4
debug1: Exit status 0
I was not even able to do git push or ferch once. I enter password and its return error:
"fatal: the remote end hung up unexpectedly"
1.) I am login as admin using just password (no ssh keys)
2.) I can connect with ssh with no problems. Can create, delete dirs... whatever...
3.) When try to push by git fatal error appear
4.) I am connecting from same machine for eleminating compatibility or network errors
5.) When use no ssh, just path "d:/git-repos/git-local.git", git working nice
SSH debug log:
debug3: Ignored env SSH_AUTH_SOCK
debug1: Sending command: powershell git-upload-pack 'd:/git-repos/git-local.git'
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
debug2: channel 0: chan_shutdown_read (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug3: send packet: type 96
debug2: channel 0: input drain -> closed
debug2: channel 0: rcvd ext data 43
fatal: the remote end hung up unexpectedly
debug2: channel 0: written 43 to efd 6
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: chan_shutdown_write (i3 o1 sock -1 wfd 5 efd 6 [write])
debug2: channel 0: output drain -> closed
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1)
debug3: send packet: type 1
debug3: fd 0 is not O_NONBLOCK
Transferred: sent 2064, received 2528 bytes, in 0.8 seconds
Bytes per second: sent 2580.9, received 3161.1
debug1: Exit status 1
SSH server config:
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey __PROGRAMDATA__/ssh/ssh_host_rsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_dsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ecdsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
SyslogFacility LOCAL0
LogLevel DEBUG3
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
# PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
# For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
# PasswordAuthentication yes
# PermitEmptyPasswords no
# GSSAPI options
#GSSAPIAuthentication no
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp sftp-server.exe
# Example of overriding settings on a per-user basis
#Match User anoncvs
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
#AllowUsers user
Match User user
ChrootDirectory "D:\git-repos"
Match User supreme
ChrootDirectory "D:\git-repos"
Match Group administrators
AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
Seems to fail on command: powershell git-receive-pack 'D:/git-repos/git-local.git'
When run command from cmd it returns:
00bdd268299939f6e8bea6ae3e78cf891b59cc79da28 refs/heads/master report-status rep
ort-status-v2 delete-refs side-band-64k quiet atomic ofs-delta object-format=sha
1 agent=git/2.30.0.windows.1
OS: Windows 7 Ultimate SP1 32bit
Using Windows 7 CMD
Git version: 2.30.0 (32bit)
OpenSSH: 8.1p1 for Windows (32bit)
Installed by this guide:
https://github.com/PowerShell/Win32-OpenSSH/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH
First I install with no option "Run Git and included Unix tools from the Windows Command Prompt". But I reinstalled it later with this option.
Env Path server:
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\ProgramsInstall\OpenSSH-Win32;
C:\ProgramsInstall\Git\cmd;
C:\ProgramsInstall\Git\mingw32\bin;
C:\ProgramsInstall\Git\usr\bin
"SSH where" command output:
C:\ProgramsInstall\OpenSSH-Win32\ssh.exe
C:\ProgramsInstall\Git\usr\bin\ssh.exe
Local repo config:
sshCommand = 'C:\\ProgramsInstall\\OpenSSH-Win32\\ssh.exe' -T -vvv
url = supreme#dev-server:D:/git-repos/git-local.git
uploadpack = powershell git-upload-pack
receivepack = powershell git-receive-pack
I am using shell script scp command to move one file from one server to another using ssh.
My command looks like this:
scp -P 23 -i $TEST_SSHKEY $DESTINATION_PATH/$FILETOCOPY $USER_ID#$SERVER_BOX:
File is copying but scp is returning return code as 1.
Why it is happening and what is the solution for this?
G'day,
Try enabling verbose mode (-v) to see more details of what's going on rather than just looking at a return code of 1 which means "something bad happened".
I have this same issue. The problem is the server on the remote end not sending an exit code. Compare these transaction excerpts.
The first causes $? = 1:
debug1: Sending command: scp -v -f /cfg/running-config
Sink: C0644 3398 running-config
running-config 100% 3398 3.3KB/s 00:00
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to xxxxx closed by remote host.
Transferred: sent 2576, received 5216 bytes, in 1.9 seconds
Bytes per second: sent 1346.9, received 2727.3
debug1: Exit status -1
The second causes $?=0:
debug1: Sending command: scp -v -f /cfg/running-config
Sink: C0644 3940 running-config
running-config 100% 3940 3.9KB/s 00:00
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to xxxxx closed by remote host.
Transferred: sent 2624, received 5984 bytes, in 1.3 seconds
Bytes per second: sent 2026.8, received 4622.2
These are two HP switches on different firmware versions. The first one is very old; the second one is new and correctly returns exit-status reply 0 to the client.