我按照以下步骤操作:
Cross compilation of openssh for ARM
Install ssh server on embedded device
1)使用以下命令构建zlib:
CC=aarch64-linux-gnu-gcc
./configure --prefix=$HOME/zlibArm --static
sudo make
sudo make install
2)使用以下命令构建OpenSSL:
export cross=aarch64-linux-gnu-
./Configure linux-aarch64 --prefix=$HOME/opensslArm no-shared -fPIC
make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"
make install
3)使用以下命令构建OpenSSH:
./configure --host=aarch64-linux-gnu --with-libs --with-zlib=$HOME/zlibArm --with-ssl-dir=$HOME/opensslArm --disable-etc-default-login CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-ar LD=aarch64-linux-gnu-gcc
4)我收到了这个错误:
/usr/lib/gcc-cross/aarch64-linux-gnu/5/../../../../aarch64-linux-gnu/bin/ld: warning: -z retpolineplt ignored.
/usr/lib/gcc-cross/aarch64-linux-gnu/5/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /home/lfpm1993/zlibArm/lib/libz.so when searching for -lz
/usr/lib/gcc-cross/aarch64-linux-gnu/5/../../../../aarch64-linux-gnu/bin/ld: /home/lfpm1993/zlibArm/lib/libz.a(inflate.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol `__stack_chk_guard@@GLIBC_2.17' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc-cross/aarch64-linux-gnu/5/../../../../aarch64-linux-gnu/bin/ld: /home/lfpm1993/zlibArm/lib/libz.a(inflate.o)(.text+0x6dc): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17'
/usr/lib/gcc-cross/aarch64-linux-gnu/5/../../../../aarch64-linux-gnu/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:172: recipe for target 'ssh' failed
make: *** [ssh] Error 1
我试图静静地在arm多功能juno r2开发板上进行ssh工作。
谢谢!
答案 0 :(得分:0)
不是一个漂亮的解决方案,但做了日志建议用-fPIC重新编译的内容我去了zlib Makefile并在所有* .o规则中添加了-fPIC。像这样:
example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -fPIC -o $@ $(SRCDIR)test/example.c
minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -fPIC -o $@ $(SRCDIR)test/minigzip.c
example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -fPIC -o $@ $(SRCDIR)test/example.c
minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -fPIC -o $@ $(SRCDIR)test/minigzip.c
adler32.o: $(SRCDIR)adler32.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)adler32.c
crc32.o: $(SRCDIR)crc32.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)crc32.c
deflate.o: $(SRCDIR)deflate.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)deflate.c
infback.o: $(SRCDIR)infback.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)infback.c
inffast.o: $(SRCDIR)inffast.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)inffast.c
inflate.o: $(SRCDIR)inflate.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)inflate.c
inftrees.o: $(SRCDIR)inftrees.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)inftrees.c
trees.o: $(SRCDIR)trees.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)trees.c
zutil.o: $(SRCDIR)zutil.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)zutil.c
compress.o: $(SRCDIR)compress.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)compress.c
uncompr.o: $(SRCDIR)uncompr.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)uncompr.c
gzclose.o: $(SRCDIR)gzclose.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)gzclose.c
gzlib.o: $(SRCDIR)gzlib.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)gzlib.c
gzread.o: $(SRCDIR)gzread.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)gzread.c
gzwrite.o: $(SRCDIR)gzwrite.c
$(CC) $(CFLAGS) $(ZINC) -c -fPIC -o $@ $(SRCDIR)gzwrite.c
所以之后,解决它编译和完美。当我做sudo make install时,我得到了这个日志:
/bin/mkdir -p /home/lfpm1993/opensshArm/etc
/home/lfpm1993/opensshArm/etc/ssh_config already exists, install will not overwrite
/home/lfpm1993/opensshArm/etc/sshd_config already exists, install will not overwrite
/home/lfpm1993/opensshArm/etc/moduli already exists, install will not overwrite
/lib/ld-linux-aarch64.so.1: No such file or directory
Makefile:379: recipe for target 'host-key' failed
make: *** [host-key] Error 255
我这样做是否正确?似乎需要花费很多精力来静态构建ssh。还有其他解决方案吗?或者这是正确的方法吗?
我只是想远程连接到主板,但我拒绝连接,我很确定我没有安装ssh,或者如果安装了它没有正确配置。我可以ping它,如果我在同一个网络中,我可以连接。
谢谢!