Skip to content

Commit

Permalink
Complete gitprep-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
gitprep committed May 16, 2014
1 parent 016a6e7 commit bb16a8a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
18 changes: 13 additions & 5 deletions script/gitprep-shell
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../extlib/lib/perl5";
use Gitprep;

my $debug = 0;

# Project name pattern
my $project_re = qr/[a-zA-Z0-9_\-\.]+$/;

Expand All @@ -27,13 +29,16 @@ my $dbi = $app->dbi;

# SSH connection
my $ssh_connection = $ENV{SSH_CONNECTION};
warn "ssh_connection: $ssh_connection" if $debug;
die "who the *heck* are you?" unless defined $ssh_connection;

# SSH original command
my $ssh_original_command = $ENV{SSH_ORIGINAL_COMMAND} || '';
warn "ssh_original_command: $ssh_original_command";

# IP address
my $ip = $ssh_connection || '(no-IP)';
warn "ip: $ip";
$ip =~ s/ .*//;

# Check new line of SSH original command
Expand All @@ -46,15 +51,19 @@ my ($verb, $project) = parse_ssh_original_command($ssh_original_command);
sanity($project);

my $rep_home = $git->rep_home;
my $repository = "'$rep_home/$project.git'";
my $repository = "'$rep_home/$user/$project.git'";
my @git_shell_cmd = ("git", "shell", "-c", "$verb $repository");
system(@git_shell_cmd) == 0
or die "Can't execute command: @git_shell_cmd" ;
warn "@git_shell_cmd" if $debug;

unless ($debug) {
system(@git_shell_cmd) == 0
or die "Can't execute command: @git_shell_cmd" ;
}

sub parse_ssh_original_command {
my $ssh_original_command = shift;

$ssh_original_command ||= 'info';
$ssh_original_command ||= '';

my $git_commands = "git-upload-pack|git-receive-pack|git-upload-archive";
if ($ssh_original_command =~ m(^($git_commands) '/?(.*?)(?:\.git)?'$)) {
Expand All @@ -74,7 +83,6 @@ sub sanity {
die "'$project' contains '..'" if $project =~ m(\.\.);
}
=head1 NAME
gitprep-shell - AuthorizedKeysCommand for sshd
Expand Down
31 changes: 31 additions & 0 deletions tmp/memo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
command="ls",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAurwDPkF1gw5Nf98BhBtPKLBEQ/AdiLIJUEreaa39aWGqzi5s4WBxBP3LMvdvqpMdbnj81ivklJTdlTbKuP4EkhVaXAtB0bw1m/oHPFpp2lH772Bj7ToZQc9omW0bqpP7CtRHCBlf10RIFnhB6ugHSETo4C/esL7OQPThHYvRd8lCGTFq9/4sVd1fWbTcreyXhQA669W+w//xNWla2KnO6+4i/P15SlZfvlgwkziaUHQRZXeVJ0toKuvQRjw5XI18Q3fORnlPALAL4ZV2vUA2Nh4wQGeEkMnXVKF92h+JrXG01filfvnPZZzSnIzVMEyA5ZHV1GhOFUzsogsBKhWrOw== [email protected]

# gitolite start
command="/home/git/gitolite/src/gitolite-shell yuku_t",
no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
ssh-rsa AAAAB3NzaC1y...== yuku_t
# gitolite end

ssh -p55555 -i ~/tmp/id_rsa_gitprep2 59.106.185.196


ssh -p55555 -i ~/tmp/id_rsa_gitprep2 git clone ssh://[email protected]:55555/home/gitprep/labo/gitprep/data/rep/kimoto/gitprep_t.git

ssh -p55555 -i ~/tmp/id_rsa_gitprep2 git-upload-pack gitprep_t.git


ssh -p55555 59.106.185.196


git clone ssh://[email protected]:55555/gitprep_t.git


�‹��ϐ� GIT_SSH

~/.ssh/config �͑�ϕ֗��ł����A Git �Ƃ͖��֌W�� SSH �ڑ����ɂ��Q�Ƃ����̂ŕs�s���Ȃ��Ƃ�����܂��B�ʂ̕��@�Ƃ��āA GIT_SSH �‹��ϐ��� SSH �̃��b�p�[�X�N���v�g���w�肷�邱�Ƃ��ł��܂��B

git-ssh.sh
#!/bin/sh
exec ssh -oIdentityFile=~/.ssh/github_id_rsa "$@"
$ GIT_SSH=git-ssh.sh git push [email protected]:kyanny/hello.git master

0 comments on commit bb16a8a

Please sign in to comment.