IBM i: ssh remotehost /QOpenSys/usr/bin/db2 \""select 123 from sysibm.sysdummy1"\" returns blank output - db2

I have found a nice hint from Kevin Adler:
$ ln -s /QOpenSys/usr/bin/qsh /QOpenSys/usr/bin/db2
which runs great in QSH both locally and also over ssh
https://kadler.io/2018/05/29/calling-qsh-utilities-from-pase.html#
/QOpenSys/usr/bin/db2 "select 123 from sysibm.sysdummy1"
and also
ssh remotehost /QOpenSys/usr/bin/db2 ""select 123 from sysibm.sysdummy1""
returns the expected 123
123
1 RECORD(S) SELECTED.
This is a handy shortcut, otherwise the command would have to be expressed as:
ssh remotehost /QOpenSys/usr/bin/system -eiqs ""CALL QSYS/QP0ZCALL ('/usr/bin/db2' 'select 123 from sysibm.sysdummy1')""
Yet on some hosts, even if /QOpenSys/usr/bin/db2 works fine locally, it returns blank output when being called over ssh. (no problem with other commands over ssh so far, all systems mentioned here are IBM i on 7.3 or 7.4)
Although there is a blank output from some of the hosts of ours for the /QOpenSys/usr/bin/db2 command the instructions get executed correctly.
create table, insert, delete... all of this gets done
ssh remotehost system ""QSYS/DSPOBJD OBJ(SCO/ROB123) OBJTYPE(*FILE)""
CPF2105: Object ROB123 in SCO type *FILE not found.
$
ssh remotehost /QOpenSys/usr/bin/db2 ""create table sco.rob123 (Number int, Name varchar(10), City varchar(10))""
$
ssh remotehost system ""QSYS/DSPOBJD OBJ(SCO/ROB123) OBJTYPE(*FILE)""
Display Object Description - Basic Page
1
5770SS1 V7R4M0 190621 REMOTEHOST 22-08-25 11:22:42 EEDS
T
Library . . . . . . . : SCO Library ASP device . : *SYSBAS
Library ASP group . . : *SYSBAS
Object Type Attribute Size Text
ROB123 *FILE PF 40960
* * * * * E N D O F L I S T I N G * * * * *
$
ssh remotehost system ""DSPFD FILE(SCO/ROB123) TYPE(*ALL)"" | grep "Total records"
Total records . . . . . . . . . . . . . . : 0
$
ssh remotehost /QOpenSys/usr/bin/db2 ""insert into sco.rob123 values (1, 'jenda', 'crhof')""
$
ssh remotehost system ""DSPFD FILE(SCO/ROB123) TYPE(*ALL)"" | grep "Total records"
Total records . . . . . . . . . . . . . . : 1
$
ssh remotehost /QOpenSys/usr/bin/db2 ""delete from sco.rob123""
$
ssh remotehost system ""DSPFD FILE(SCO/ROB123) TYPE(*ALL)"" | grep "Total records"
Total records . . . . . . . . . . . . . . : 0
$
ssh remotehost /QOpenSys/usr/bin/db2 ""insert into sco.rob123 values (1, 'jenda', 'crhof')""
$
ssh remotehost system ""DSPFD FILE(SCO/ROB123) TYPE(*ALL)"" | grep "Total records"
Total records . . . . . . . . . . . . . . : 1
$
ssh remotehost /QOpenSys/usr/bin/db2 ""select * from sco.rob123""
$
ssh -v remotehost /QOpenSys/usr/bin/db2 ""select * from sco.rob123""
OpenSSH_8.0p1, OpenSSL 1.1.1l 24 Aug 2021
debug1: Reading configuration data /QOpenSys/QIBM/ProdData/SC1/OpenSSH/etc/ssh_config
debug1: Connecting to remotehost [10.1.1.10] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type 0
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: identity file /home/user/.ssh/id_xmss type -1
debug1: identity file /home/user/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.0
debug1: match: OpenSSH_8.0 pat OpenSSH* compat 0x04000000
debug1: Authenticating to remotehost:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305#openssh.com MAC: compression: none
debug1: kex: client->server cipher: chacha20-poly1305#openssh.com MAC: compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:WOjO7zT1MIS3NeMhPq786/0GVGbZYlGXhDnFOlRpL7k
debug1: Host 'remotehost' is known and matches the ECDSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:50
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/user/.ssh/id_rsa RSA SHA256:mP1UusmDO6fvA+67200rZHR+XC2hMZTITEejMuWZRZw
debug1: Will attempt key: /home/user/.ssh/id_dsa
debug1: Will attempt key: /home/user/.ssh/id_ecdsa
debug1: Will attempt key: /home/user/.ssh/id_ed25519
debug1: Will attempt key: /home/user/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2
-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /home/user/.ssh/id_rsa RSA SHA256:mP1UusmDO6fvA+67200rZHR+XC2hMZTITEejMuWZRZw
debug1: Server accepts key: /home/user/.ssh/id_rsa RSA SHA256:mP1UusmDO6fvA+67200rZHR+XC2hMZTITEejMuWZRZw
debug1: Authentication succeeded (publickey).
Authenticated to remotehost ([10.1.1.10]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00#openssh.com want_reply 0
debug1: Remote: /home/user/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/user/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Sending command: /QOpenSys/usr/bin/db2 "select * from sco.rob123"
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow#openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3132, received 2860 bytes, in 0.4 seconds
Bytes per second: sent 7799.9, received 7122.5
debug1: Exit status 0
$
And I keep failing to find out why the output for this particular command /QOpenSys/usr/bin/db2 on a handful of our systems is blank.
Does any one, please, have any clue?
Thank you

it came out it was not specifically about db2 but more in general the use of
/QOpenSys/usr/bin/system (/QOpenSys/QIBM/ProdData/OS400/PASE/bin/system)
did not provide any output at all when called over ssh
Resolution:
The IBM /QOpenSys/usr/bin/qsh
contains at the end of the script
...
exec /QOpenSys/usr/bin/system -eiqs "CALL QSYS/QP0ZCALL ('/usr/bin/$basename' $args)"
and after omitting the "s" parameter:
exec /QOpenSys/usr/bin/system -eiq "CALL QSYS/QP0ZCALL ('/usr/bin/$basename' $args)"
all /usr/bin/... commands wrapped into /QOpenSys/usr/bin/system provide the output even when called over ssh.
So now it is time to inspect CCSIDs
( https://www.ibm.com/docs/en/i/7.3?topic=utilities-pase-i-system-utility )

Related

Can push by SSH via Git Bash but cannot on Github Desktop

https://github.com/desktop/desktop/issues/11840
Version & OS
Win 10 21H1 Github Desktop 2.6.6
Steps to reproduce the behavior
On Git Bash:
19000#FIRESTAR MINGW64 /d/My-LaTeX-Files (master)
$ git remote -v
origin git#github.com:1900011604/My-LaTeX-Files.git (fetch)
origin git#github.com:1900011604/My-LaTeX-Files.git (push)
19000#FIRESTAR MINGW64 /d/My-LaTeX-Files (master)
$ git push
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 686 bytes | 343.00 KiB/s, done.
Total 8 (delta 6), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (6/6), completed with 3 local objects.
To github.com:1900011604/My-LaTeX-Files.git
1f5ff72..192e0af master -> master
On Github Desktop
Click "Push Origin"
If you use SSH authentication, check that your key is added to the ssh-agent and associated with your account.
Below are outputs on Git Bash:
19000#FIRESTAR MINGW64 /d/My-LaTeX-Files (master)
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /c/Users/19000/.ssh/id_rsa:
Identity added: /c/Users/19000/.ssh/id_rsa (/c/Users/19000/.ssh/id_rsa)
19000#FIRESTAR MINGW64 /d/My-LaTeX-Files (master)
$ ssh-add -l -E sha256
2048 SHA256:(**deleted due to safety reasons**) /c/Users/19000/.ssh/id_rsa (RSA)
19000#FIRESTAR MINGW64 /d/My-LaTeX-Files (master)
$ ssh -vT git#github.com
OpenSSH_8.5p1, OpenSSL 1.1.1j 16 Feb 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [140.82.113.4] port 22.
debug1: Connection established.
debug1: identity file /c/Users/19000/.ssh/id_rsa type 0
debug1: identity file /c/Users/19000/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/19000/.ssh/id_dsa type -1
debug1: identity file /c/Users/19000/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/19000/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/19000/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/19000/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/19000/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/19000/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/19000/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/19000/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/19000/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/19000/.ssh/id_xmss type -1
debug1: identity file /c/Users/19000/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.5
debug1: Remote protocol version 2.0, remote software version babeld-c2015ddc
debug1: compat_banner: no match: babeld-c2015ddc
debug1: Authenticating to github.com:22 as 'git'
debug1: load_hostkeys: fopen /c/Users/19000/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: load_hostkeys: fopen /c/Users/19000/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/19000/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/19000/.ssh/id_rsa RSA SHA256:(**deleted due to safety reasons**) agent
debug1: Will attempt key: /c/Users/19000/.ssh/id_dsa
debug1: Will attempt key: /c/Users/19000/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/19000/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/19000/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/19000/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/19000/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519-cert-v01#openssh.com,ecdsa-sha2-nistp521-cert-v01#openssh.com,ecdsa-sha2-nistp384-cert-v01#openssh.com,ecdsa-sha2-nistp256-cert-v01#openssh.com,sk-ssh-ed25519-cert-v01#openssh.com,sk-ecdsa-sha2-nistp256-cert-v01#openssh.com,rsa-sha2-512-cert-v01#openssh.com,rsa-sha2-256-cert-v01#openssh.com,ssh-rsa-cert-v01#openssh.com,ssh-dss-cert-v01#openssh.com,sk-ssh-ed25519#openssh.com,sk-ecdsa-sha2-nistp256#openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/19000/.ssh/id_rsa RSA SHA256:(**deleted due to safety reasons**) agent
debug1: Server accepts key: /c/Users/19000/.ssh/id_rsa RSA SHA256:(**deleted due to safety reasons**) agent
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.113.4]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: filesystem full
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi 1900011604! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2832, received 2612 bytes,
in 0.7 seconds
Bytes per second: sent 4077.5, received 3760.7
debug1: Exit status 1
I suspect your message "If you use SSH authentication, check that your key is added to the ssh-agent and associated with your account." is part of the following error dialog box:
Try and add your ssh key again: ssh-add /path/to/key
If not, check desktop/desktop issue 8860
Check the GitHub Desktop logs: Help > Show Logs in Finder (macOS) or Explorer (Windows).
Check if signing out/back in from GitHub Desktop is enough.
This answer https://stackoverflow.com/a/29380765/2849383 saved my entire life.
Try the following
$ eval "$(ssh-agent -s)"
$ ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
If you have a SSH key with a passphrase it will not work with GitHub Desktop.
Recreate a new SSH key with no passphrase.
This litteraly saved my hole miserable life.

Can't push to github with SourceTree despite having identity added in agent: Permission denied (publickey)

If I run ssh-add -l I see my identity in the list as expected. If I run ssh -vT git#github.com I get this output:
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/myself/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to github.com [140.82.113.4] port 22.
debug1: Connection established.
debug1: identity file /Users/myself/.ssh/id_rsa type -1
debug1: identity file /Users/myself/.ssh/id_rsa-cert type -1
debug1: identity file /Users/myself/.ssh/id_dsa type -1
debug1: identity file /Users/myself/.ssh/id_dsa-cert type -1
debug1: identity file /Users/myself/.ssh/id_ecdsa type -1
debug1: identity file /Users/myself/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/myself/.ssh/id_ed25519 type -1
debug1: identity file /Users/myself/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/myself/.ssh/id_xmss type -1
debug1: identity file /Users/myself/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version babeld-849b9b5f
debug1: no match: babeld-849b9b5f
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/myself/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: Generated by Sourcetree on macOS for myself-GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc agent
debug1: Will attempt key: /Users/myself/.ssh/id_rsa
debug1: Will attempt key: /Users/myself/.ssh/id_dsa
debug1: Will attempt key: /Users/myself/.ssh/id_ecdsa
debug1: Will attempt key: /Users/myself/.ssh/id_ed25519
debug1: Will attempt key: /Users/myself/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: Generated by Sourcetree on macOS for myself-GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc agent
debug1: Server accepts key: Generated by Sourcetree on macOS for myself-GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc agent
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.113.4]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_TERMINAL_VERSION = 3.3.8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_TERMINAL = iTerm2
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi myself! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3564, received 2484 bytes, in 0.2 seconds
Bytes per second: sent 18846.5, received 13135.4
debug1: Exit status 1
I still can't push code to github despite getting the You've successfully authenticated message in this debug output, the SSH identity being generated by SourceTree itself, and ensuring my SSH Agent is running by doing eval "$(ssh-agent)".
I can also see the expected key in my github profile.
What is wrong here?
my SSH Agent is running by doing eval "$(ssh-agent)".
This is likely the problem. ssh knows to talk to ssh-agent via the SSH_AUTH_SOCK environment variables. Environment variables are only visible to a process and its children.
eval "$(ssh-agent)" sets SSH_AUTH_SOCK for this shell and its children only; that is anything you ran from that shell. If you then run git in this shell it should work. But if you have some stand alone program not launched from this shell, like Atlassian Sourcetree, when it runs ssh it will not know to talk to that ssh-agent.
You could launch Sourcetree from that shell, but that's not a very good solution.
To fix this, and a host of other ssh related problems, start your ssh-agent at login. This should be done for you by your operating system, or if not follow the instructions for your operating system. Otherwise, follow the advice in the various answers here.

Net::SCP scp exited with non-success state: 256 at test.pl line 27

I have searched all the internet for this code of error. The only place left is your human minds.
Here's my code:
#!/usr/bin/perl
use strict;
use Net::FTP;
use Net::SCP;
use Net::SCP::Expect;
my $ip = "192.168.141.131";
my $username = "user_backup";
my $password = "ubuntu";
my $tfr_type = "scp";
my $file = "/home/osboxes/Desktop/ConteudosServer/backupsystem/backups/Fri_11_Dec_21.18.14_iā€Œā€‹_2015";
my $dest = "/home/user_backup/backups/aqui.txt";
my $scp = Net::SCP::Expect->new(
host => $ip,
user => $username,
password => $password,
auto_yes => 1,
verbose => 1,
debug => 1,
timeout_auto => 1,
);
$scp->scp($file, $dest);
print "Source: $file\n";
print "Desti: $dest\n";
I don't where it goes wrong. It says line 26: $scp->scp($file, $dest); but I don't know where it is wrong.
EDIT
As Kenster's sugested (thank you bro) here is the scp -v /home/osboxes/Desktop/ConteudosServer/backupsystem/backups/Fri_11_Dec_21.18.14_i_2015 user_backup#192.168.141.131:/home/user_backup/backups/aqui.txt > /tmp/rapid.txt command:
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.141.131 [192.168.141.131] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr umac-64-etm#openssh.com none
debug1: kex: client->server aes128-ctr umac-64-etm#openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 30:af:e0:62:a2:cd:f9:e0:ae:43:2a:d8:b9:b3:e5:72
debug1: Host '192.168.141.131' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:2
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
user_backup#192.168.141.131's password:
debug1: Authentication succeeded (password).
Authenticated to 192.168.141.131 ([192.168.141.131]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_GB.UTF-8
debug1: Sending command: scp -v -t /home/user_backup/backups/aqui.txt
Sending file modes: C0644 104540 Fri_11_Dec_21.18.14_i_2015
Sink: C0644 104540 Fri_11_Dec_21.18.14_i_2015
scp: /home/user_backup/backups/aqui.txt: Permission denied
root#osboxes:/home/osboxes/Desktop/ConteudosServer/backupsystem# 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
Transferred: sent 2636, received 2344 bytes, in 0.2 seconds
Bytes per second: sent 12676.0, received 11271.8
debug1: Exit status 1

github ssh connection setup

I get Permission denied (publickey). on Windows 7 x64
What i did is:
1) Updated my git + openSSH as well
2) generated keys with ssh-keygen -t rsa -b 4096 -C "myemail#gmailcom"
3) named them 'hub', so i have hub + hub.pub in .ssh folder
4) run ssh-agent -s
5) run ssh-agent sh -c 'ssh-add ./hub'
it said identity added, i can't run "eval $(ssh-agent -s)" on windows so i found "sh -c" (by the waywhy everyone write only unix like instructions always ( )
6) added my public key into github SSH keys list in my github account
7) ssh -vT git#github.com
Full log:
C:\Users\ra\.ssh>ssh -vT git#github.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to github.com [192.30.252.131] port 22.
debug1: Connection established.
debug1: identity file /.ssh/identity type -1
debug1: identity file /.ssh/id_rsa type -1
debug1: identity file /.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-sha1 none
debug1: kex: client->server aes128-cbc hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/identity
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
Why i should to do else?
debug1: Trying private key: /.ssh/identity
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
You are trying to connect with (wrong?) keys from these files.
So may this can help you?
I am sure there is a config file like this on Windows?
Eventually i have figured out, that i had several GIT installed on my computer. One was in Program Files, and the other was in Program Files x64 (old one). Seems old version wasn't removed completely during installation or newer one.
After i had uninstalled both and installed new one it works fine.

Permission denied public key with Cap, but I can ssh into github

So I've been wrestling with Capistrano a lot, and I think I've always got it to deploy.
The issue I'm having now is that doing a cap deploy gives me:
Chintan at mbp in ~/Documents/Work/faxattach on master!
Ā± cap deploy
/Users/Chintan/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.2.3/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
triggering load callbacks
* 2013-07-03 16:13:56 executing `staging'
triggering start callbacks for `deploy'
* 2013-07-03 16:13:56 executing `multistage:ensure'
* 2013-07-03 16:13:56 executing `deploy'
* 2013-07-03 16:13:56 executing `deploy:update'
** transaction: start
* 2013-07-03 16:13:56 executing `deploy:update_code'
executing locally: "git ls-remote git#github.com:chintanparikh/faxattach.git HEAD"
command finished in 611ms
* executing "git clone -q git#github.com:chintanparikh/faxattach.git /srv/www/faxattach/releases/20130703201357 && cd /srv/www/faxattach/releases/20130703201357 && git checkout -q -b deploy a237b155f1fe4acef23ad4b594749c567a213117 && (echo a237b155f1fe4acef23ad4b594749c567a213117 > /srv/www/faxattach/releases/20130703201357/REVISION)"
servers: ["faxattach-staging-new"]
[faxattach-staging-new] executing command
** [faxattach-staging-new :: out] Permission denied (publickey).
** [faxattach-staging-new :: out] fatal: The remote end hung up unexpectedly
command finished in 1286ms
*** [deploy:update_code] rolling back
* executing "rm -rf /srv/www/faxattach/releases/20130703201357; true"
servers: ["faxattach-staging-new"]
[faxattach-staging-new] executing command
command finished in 572ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p327#faxattach' -c 'git clone -q git#github.com:chintanparikh/faxattach.git /srv/www/faxattach/releases/20130703201357 && cd /srv/www/faxattach/releases/20130703201357 && git checkout -q -b deploy a237b155f1fe4acef23ad4b594749c567a213117 && (echo a237b155f1fe4acef23ad4b594749c567a213117 > /srv/www/faxattach/releases/20130703201357/REVISION)'" on faxattach-staging-new
However, if I manually ssh into my server and then do a ssh -vT git#github.com, it works fine:
faxattach at ip-10-164-71-243 in ~
ā—‹ ssh -vT git#github.com
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: identity file /home/faxattach/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/faxattach/.ssh/id_rsa-cert type -1
debug1: identity file /home/faxattach/.ssh/id_dsa type -1
debug1: identity file /home/faxattach/.ssh/id_dsa-cert type -1
debug1: identity file /home/faxattach/.ssh/id_ecdsa type -1
debug1: identity file /home/faxattach/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
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
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/faxattach/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/faxattach/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([204.232.175.90]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
debug1: Remote: Forced command: gerve chintanparikh c3:ff:25:e1:30:be:c7:37:51:b5:87:7c:46:dc:c0:c7
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command: gerve chintanparikh c3:ff:25:e1:30:be:c7:37:51:b5:87:7c:46:dc:c0:c7
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_CTYPE = en_US.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow#openssh.com reply 0
Hi chintanparikh! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2816, received 2984 bytes, in 0.1 seconds
Bytes per second: sent 33714.5, received 35725.9
debug1: Exit status 1
Any ideas?
Add this to your config/deploy.rb
set :ssh_options, { :forward_agent => true }
If you're using your own private keys for git, you want to tell Capistrano to use agent forwarding with this command. Agent forwarding can make key management much simpler as it uses your local keys instead of keys installed on the server.
Source: Agent Forwarding Topic.
and make sure the user is not sudo in config/deploy.rb:
set :use_sudo, false
as in the logs you have attached, you are logged in as faxattach ( which is perhaps not sudo).
The ssh connection that fails is made to the server, not to github.
You should check if you can get on the server with this key.
If not you should add the public key to the servers .ssh/authorized_keys.
Also check if the user for the server is correct and exists.